From cd5462527022d31d21e1c3df78236b9e159177ec Mon Sep 17 00:00:00 2001 From: ageay Date: Fri, 19 Nov 2004 09:25:16 +0000 Subject: [PATCH] *** empty log message *** --- src/PatchQt/BUGS_DESCRIPTION | 250 +++++++++++++++++++++++ src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx | 5 + src/SALOME_PYQT/SALOME_PYQT_GUI.cxx | 6 +- src/SALOME_PYQT/SALOME_PYQT_GUI.h | 3 +- src/SALOME_PYQT/SalomePyQt.cxx | 11 + src/SALOME_PYQT/SalomePyQt.hxx | 11 + src/SALOME_PYQT/SalomePyQt.sip | 11 + src/SALOME_SWIG/batchmode_salome.py | 32 ++- src/TOOLSDS/SALOMEDS_Tool.cxx | 103 +++++++++- src/TOOLSDS/SALOMEDS_Tool.hxx | 39 +++- src/TOOLSGUI/Makefile.in | 8 +- src/TOOLSGUI/ToolsGUI.cxx | 106 ++++++++-- src/TOOLSGUI/ToolsGUI.h | 38 ++-- 13 files changed, 561 insertions(+), 62 deletions(-) create mode 100644 src/PatchQt/BUGS_DESCRIPTION diff --git a/src/PatchQt/BUGS_DESCRIPTION b/src/PatchQt/BUGS_DESCRIPTION new file mode 100644 index 000000000..ecd2a82be --- /dev/null +++ b/src/PatchQt/BUGS_DESCRIPTION @@ -0,0 +1,250 @@ +********************************************************************* +* File : BUGS_DESCRIPTION +* Project : PAL/SALOME +* Module : PatchQt +* Author : Vadim SANDLER +* Created : 03/11/2004 +********************************************************************* + +This file contains description of bugs found in Qt 3.0.5 classes and patches with bug-fixes and improvements done for Qt classes +in frames of PAL/SALOME project. + +Main principles of the patches creation: +* the original classes are renamed by adding "P" suffix to the class name; +* private Qt classes are copied to patched files in order to avoid compilation/linking problems; +* classes definitions are moved from *.cpp implementation to *.h header in order to avoid additional moc preprocessing for *.cpp files. + +********************************************************************* + +Bug: keyboard accelerators for actions (menu, toolbar, etc) are not disabled when action itself is disabled (grayed). + +Gravity: medium + +Patched file(s): +* qactionP.cxx: +1) void QActionPrivate::update() +- enable/disable key accelerator according to the action state + +********************************************************************* + +Bug: Wrong MDI behaviour +To reproduce in SALOME: +1. Create new study +- Window Study1#1 appears and becomes active +2. Create one more study +- Window Study2#1 appears and becomes active (Study1#1 becames inactive) +3. Minimize Study2#1 window +- Window Study2#1 is minimized, Study1#1 becames active +4. Minimize Study1#1 window +- Window Study1#1 is minimized but stays still active (highlighted title) +5. Menu command "File/Close" +- Study2 document is closed, but should Study1 !!! + +Gravity: high + +Bug: Crash on close study window +To reproduce in SALOME: +1. Launch application. +2. Create new study with any Viewer. +3. Create second new study. +4. Close second study. +-> crash + +Gravity: high + +Bug: crash when leaving a study +To reproduce in SALOME: +1. Create new study +2. Load VISU component +3. Menu Window / New Window / Plot2d Viewer +4. Miximize Study 1#2 window (with Plot2d viewer) +5. Menu File / Close +6. Press "Close w/o saving" button in "Close Active Study" dialog box. +-> crash + +Gravity: high + +Patched files(s): +* qworkspaceP.h: +- methods +void QWorkspace::activateNextWindow() +void QWorkspace::activatePreviousWindow() +void QWorkspace::activateWindow( QWidget* w, bool change_focus = TRUE ) +are made public + +* qworkspaceP.cxx: +- methods +void QWorkspace::childEvent( QChildEvent * e) +void QWorkspace::activateWindow( QWidget* w, bool change_focus ) +void QWorkspace::minimizeWindow( QWidget* w) +bool QWorkspace::eventFilter( QObject *o, QEvent * e) +void QWorkspace::activatePreviousWindow() +are modified to activate correct child window on maximizing/minimizing/closing etc operations and to avoid crashes. + +********************************************************************* + +Improvement: Add controls to allow collapse/expand parts of view frame. +The patch adds buttons with small arrows for splitter which allow to collapse/restore splitter in both (left/right or top/botton) directions. + +Gravity: medium + +Bug: Splitter is not shown in python console +To reproduce in SALOME: +1. Create new study +2. Open new window (VTK or OCC) -> python console and message console is hidden +3. Restore normal size of low frames (python and message consoles) by clicking corresponding splitter button. +-> horizontal scrolbars for this windows are not shown, i.e. python and message frames are clipped. + +Gravity: medium + +Bug: Splitter does not restore its original position after collapsing/expanding operations. +To reproduce try to collapse/expand repeatedly any splitter (e.g. that one between Python and Message consoles). + +Gravity: medium + +Improvement: Implement a functionality (for VISU module) to control the Viewers behavior from python console - concerning QSplitter it means a possibility +to show/hide different parts of view frame (Object Browser, Python Console, 3d/2d viewer, Python console, Message window). + +Gravity: high + +Patched file(s): +* qsplitterP.h +1) to process correctly resizing events: +- methods +QSizePolicy QSplitter::sizePolicy() const +QSizePolicy QSplitterHandle::sizePolicy() const; +are added + +2) to allow collapse/expand functionality: +- methods +bool QSplitter::isCompressEnabled() const; +void QSplitter::setCompressEnabled(bool on); +void QSplitter::compress(QWidget*); +void QSplitter::unCompress(QWidget*); +QSplitterHandle* QSplitter::getHandleAfter(QWidget* w); +QSplitterHandle* QSplitter::getHandleBefore(QWidget* w); +bool QSplitter::isCompressed( const QWidget* ) const; +QWidget* QSplitter::widgetBefore( int id ) const; +QWidget* QSplitter::widgetAfter( int id ) const; +QSize QSplitter::minSize( const QWidget *w ) const; +QSize QSplitter::maxSize( const QWidget *w ) const; +int QSplitter::hit( QPoint p ); +void QSplitter::updateSplitterHandles() const; +and +void QSplitterHandle::updateButtonState(); +void QSplitterHandle::compressAfter(); +void QSplitterHandle::unCompressAfter(); +void QSplitterHandle::compressBefore(); +void QSplitterHandle::unCompressBefore(); +void QSplitterHandle::onBeforeCompress(); +void QSplitterHandle::onAfterCompress(); +void QSplitterHandle::onBeforeUnCompress(); +void QSplitterHandle::onAfterUnCompress(); +are added + +- fields: +QWidgetList QSplitter::compressed_widgets; +bool QSplitter::compress_flag; +and +int QSplitterHandle::oldpos; +QPushButton* QSplitterHandle::left; +QPushButton* QSplitterHandle::right; +QPushButton* QSplitterHandle::unleft; +QPushButton* QSplitterHandle::unright; +are added + +- method +void QSplitter::setG( QWidget *w, int p, int s ); +is modified + +* qsplitterP.cxx: +1) to draw button arrows: +static const char* splitter_left_xpm[]; +static const char* splitter_right_xpm[]; +static const char* splitter_up_xpm[]; +static const char* splitter_down_xpm[]; +are added + +2) to process correctly resizing events: +- methods +QSizePolicy QSplitter::sizePolicy() const +QSizePolicy QSplitterHandle::sizePolicy() const; +are added + +3) to allow collapse/expand functionality: +- methods +bool QSplitter::isCompressEnabled() const; +void QSplitter::setCompressEnabled(bool on); +void QSplitter::compress(QWidget*); +void QSplitter::unCompress(QWidget*); +QSplitterHandle* QSplitter::getHandleAfter(QWidget* w); +QSplitterHandle* QSplitter::getHandleBefore(QWidget* w); +bool QSplitter::isCompressed( const QWidget* ) const; +QWidget* QSplitter::widgetBefore( int id ) const; +QWidget* QSplitter::widgetAfter( int id ) const; +QSize QSplitter::minSize( const QWidget *w ) const; +QSize QSplitter::maxSize( const QWidget *w ) const; +int QSplitter::hit( QPoint p ); +void QSplitter::updateSplitterHandles() const; +and +void QSplitterHandle::updateButtonState(); +void QSplitterHandle::compressAfter(); +void QSplitterHandle::unCompressAfter(); +void QSplitterHandle::compressBefore(); +void QSplitterHandle::unCompressBefore(); +void QSplitterHandle::onBeforeCompress(); +void QSplitterHandle::onAfterCompress(); +void QSplitterHandle::onBeforeUnCompress(); +void QSplitterHandle::onAfterUnCompress(); +are added + +- methods +QSplitterHandle::QSplitterHandle() +void QSplitter::setG( QWidget *w, int p, int s ); +QSize QSplitterHandle::sizeHint() const +void QSplitterHandle::setOrientation( Qt::Orientation o ) +void QSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) +void QSplitterHandle::paintEvent( QPaintEvent * ) +void QSplitter::init() +void QSplitter::setOrientation( Orientation o ) +QSplitterLayoutStruct *QSplitter::addWidget( QWidget *w, bool first ) +void QSplitter::setRubberband( int p ) +void QSplitter::drawSplitter( QPainter *p, QCOORD x, QCOORD y, QCOORD w, QCOORD h ) +void QSplitter::moveSplitter( QCOORD p, int id ) +void QSplitter::moveBefore( int pos, int id, bool upLeft ) +void QSplitter::moveAfter( int pos, int id, bool upLeft ) +void QSplitter::getRange( int id, int *min, int *max ) +void QSplitter::doResize() +void QSplitter::recalc( bool update ) +void QSplitter::styleChange( QStyle& old ) +are modified: + +********************************************************************* + +Bug: File names filter of the "Open" and "Save" dialog boxes is broken +To reproduce in SALOME: +1) start PAL/SALOME +2) open new study with the help of OCC Viewer and load Geometry module +3) Menu File / Import / BRep +4) Browse to any directory may be changed by yourself +5) Press "Create New Folder" button of the "Import" dialog box +6) Browse to created directory "New Folder 1" +7) Press "Create New Folder" button of the "Import" dialog box +8) Browse to created directory "New Folder 1" +9) Delete first created "New Folder 1" directory externally (e.g. from any terminal window) +10) Press "One directory up" button of the "Import" dialog box +11) Error message box appears: "Could not read directory .../New Folder 1/New Folder 1" - press OK button to close message box. +-> Result: "BREP Files (*.brep)" filter is set as "File type" in the "Import" dialog box, but non-BREP files are also visible and available for the selection +in the browser window of the "Import" dialog box +-> The same situation takes place for the "Export" dialog box. + +Gravity: low + +Patch: +* qfiledialogP.cxx: +1) methods +void QFileDialogP::urlFinished( QNetworkOperation *op ) +is modified to fix bug + +********************************************************************* + diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx index 125152fed..b5f8c37e2 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx @@ -67,6 +67,8 @@ #include "SALOMEDS_AttributeSelectable_i.hxx" #include "SALOMEDS_AttributeExpandable_i.hxx" #include "SALOMEDS_AttributeOpened_i.hxx" +#include "SALOMEDS_AttributeFlags_i.hxx" +#include "SALOMEDS_AttributeGraphic_i.hxx" #include "SALOMEDS_AttributeTextColor_i.hxx" #include "SALOMEDS_AttributeTextHighlightColor_i.hxx" #include "SALOMEDS_AttributePixMap_i.hxx" @@ -82,6 +84,7 @@ #include #include + using namespace std; #define USE_CASE_LABEL_TAG 2 @@ -561,6 +564,8 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA __FindOrCreateAttribute(SALOMEDS_StudyPropertiesAttribute, AttributeStudyProperties) __FindOrCreateAttribute(SALOMEDS_ExternalFileDef, AttributeExternalFileDef) __FindOrCreateAttribute(SALOMEDS_FileType, AttributeFileType) + __FindOrCreateAttribute(SALOMEDS_FlagsAttribute, AttributeFlags) + __FindOrCreateAttribute(SALOMEDS_GraphicAttribute, AttributeGraphic) if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) { Standard_GUID aTreeNodeGUID; diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUI.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUI.cxx index 7bc439ab1..09c9227a7 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI.cxx @@ -1,4 +1,3 @@ -using namespace std; //============================================================================= // File : SALOME_PYQT_GUI.cxx // Created : mer jun 4 17:17:20 UTC 2003 @@ -338,7 +337,8 @@ bool SALOME_PYQT_GUI::ActiveStudyChanged( QAD_Desktop* parent ) * no call to python module.BuildPresentation() (not yet ???) */ //============================================================================= -void SALOME_PYQT_GUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& theIO ) +void SALOME_PYQT_GUI::BuildPresentation( const Handle(SALOME_InteractiveObject)&, + QAD_ViewFrame* ) { } @@ -347,7 +347,7 @@ void SALOME_PYQT_GUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& * no call to python module.SupportedViewType() (not yet ???) */ //============================================================================= -void SALOME_PYQT_GUI::SupportedViewType(int* buffer, int bufferSize) +void SALOME_PYQT_GUI::SupportedViewType(int* /*buffer*/, int /*bufferSize*/ ) { } diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUI.h b/src/SALOME_PYQT/SALOME_PYQT_GUI.h index 2e7617d5a..eb1ca4861 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI.h +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI.h @@ -38,7 +38,8 @@ public: 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 BuildPresentation ( const Handle(SALOME_InteractiveObject)& theIO, + QAD_ViewFrame* = 0 ); virtual void SupportedViewType (int* buffer, int bufferSize); virtual void Deactivate (); void initInterp(int studyId); diff --git a/src/SALOME_PYQT/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt.cxx index 370280259..863616548 100644 --- a/src/SALOME_PYQT/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt.cxx @@ -8,6 +8,7 @@ #include "SalomePyQt.hxx" #include +#include #include "QAD_Application.h" #include "QAD_Desktop.h" @@ -19,6 +20,7 @@ #include "QAD_Config.h" #include "QAD_Settings.h" + using namespace std; QWidget* SalomePyQt::getDesktop() @@ -149,3 +151,12 @@ bool SalomePyQt::dumpView(const QString& filename) } return false; } + +QPopupMenu* SalomePyQt::getPopupMenu( const MenuName menu ) +{ + QMenuBar* mainMenu = QAD_Application::getDesktop()->getMainMenuBar(); + if ( mainMenu->findItem( menu ) ) { + return mainMenu->findItem( menu )->popup(); + } + return 0; +} diff --git a/src/SALOME_PYQT/SalomePyQt.hxx b/src/SALOME_PYQT/SalomePyQt.hxx index b70d39dfe..91c369aff 100644 --- a/src/SALOME_PYQT/SalomePyQt.hxx +++ b/src/SALOME_PYQT/SalomePyQt.hxx @@ -15,12 +15,23 @@ #include #include +enum MenuName { + File = 1, + View = 2, + Edit = 3, + Preferences = 4, + Tools = 5, + Window = 6, + Help = 7 +}; + class SalomePyQt { public: static QWidget* getDesktop(); static QWorkspace* getMainFrame(); static QMenuBar* getMainMenuBar(); + static QPopupMenu* getPopupMenu( const MenuName menu ); static SALOME_Selection* getSelection(); static int getStudyId(); static void putInfo( const QString& ); diff --git a/src/SALOME_PYQT/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt.sip index fe6a9d43a..df84b3fc1 100644 --- a/src/SALOME_PYQT/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt.sip @@ -17,6 +17,16 @@ signals: void currentSelectionChanged(); }; +enum MenuName { + File = 1, + View = 2, + Edit = 3, + Preferences = 4, + Tools = 5, + Window = 6, + Help = 7 +}; + class SalomePyQt { %HeaderCode @@ -27,6 +37,7 @@ public: static QWidget* getDesktop(); static QWorkspace* getMainFrame(); static QMenuBar* getMainMenuBar(); + static QPopupMenu* getPopupMenu( const MenuName ); static SALOME_Selection* getSelection(); static int getStudyId(); static void putInfo( const QString& ); diff --git a/src/SALOME_SWIG/batchmode_salome.py b/src/SALOME_SWIG/batchmode_salome.py index c997d9fa6..87edd913b 100644 --- a/src/SALOME_SWIG/batchmode_salome.py +++ b/src/SALOME_SWIG/batchmode_salome.py @@ -215,24 +215,44 @@ def FindFileInDataDir(filename): # initialise the ORB orb = None -while orb == None: +step = 0 +while step < 100 and orb is None: orb = CORBA.ORB_init([''], CORBA.ORB_ID) + step = step + 1 + time.sleep(4) + +if orb is None: + print "Warning: ORB has not been initialized !!!" # create an LifeCycleCORBA instance lcc = LifeCycleCORBA(orb) -while lcc._catalog == None: +step = 0 +while step < 100 and lcc._catalog is None: lcc = LifeCycleCORBA(orb) - + step = step + 1 + time.sleep(4) + +if lcc._catalog is None: + print "Warning: LifeCycleCORBA object is incomplete !!!" + #create a naming service instance naming_service = SALOME_NamingServicePy_i(orb) # get Study Manager reference -obj=None -while obj == None: - obj = naming_service.Resolve('myStudyManager') +obj = None + +step = 0 +while step < 100 and obj == None: + obj = naming_service.Resolve('myStudyManager') + step = step + 1 + time.sleep(4) + myStudyManager = obj._narrow(SALOMEDS.StudyManager) +if myStudyManager is None: + print "Warning: SALOMEDS.StudyManager has not been created !!!" + # create new study aListOfOpenStudies = myStudyManager.GetOpenStudies(); myStudy = None; diff --git a/src/TOOLSDS/SALOMEDS_Tool.cxx b/src/TOOLSDS/SALOMEDS_Tool.cxx index 4e07ddf04..81d646b60 100644 --- a/src/TOOLSDS/SALOMEDS_Tool.cxx +++ b/src/TOOLSDS/SALOMEDS_Tool.cxx @@ -25,6 +25,9 @@ #include #include + +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + using namespace std; //============================================================================ @@ -249,7 +252,6 @@ SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream, if(aBuffer == NULL) return NULL; - long aBufferSize = theStream.length(); long aFileSize, aCurrentPos = 4; int i, aFileNameSize, aNbFiles = 0; @@ -310,3 +312,102 @@ std::string SALOMEDS_Tool::GetDirFromPath(const char* thePath) { aDirString.ChangeAll('|','/'); return aDirString.ToCString(); } + +//======================================================================= +// name : GetFlag +// Purpose : Retrieve specified flaf from "AttributeFlags" attribute +//======================================================================= +bool SALOMEDS_Tool::GetFlag( const int theFlag, + SALOMEDS::Study_var theStudy, + SALOMEDS::SObject_var theObj ) +{ + SALOMEDS::GenericAttribute_var anAttr; + if ( !theObj->_is_nil() && theObj->FindAttribute( anAttr, "AttributeFlags" ) ) + { + SALOMEDS::AttributeFlags_var aFlags = SALOMEDS::AttributeFlags::_narrow( anAttr ); + return aFlags->Get( theFlag ); + } + + return false; +} + +//======================================================================= +// name : SetFlag +// Purpose : Set/Unset specified flaf from "AttributeFlags" attribute +//======================================================================= +bool SALOMEDS_Tool::SetFlag( const int theFlag, + SALOMEDS::Study_var theStudy, + const char* theEntry, + const bool theValue ) +{ + SALOMEDS::SObject_var anObj = theStudy->FindObjectID( theEntry ); + + if ( !anObj->_is_nil() ) + { + SALOMEDS::GenericAttribute_var aGAttr; + if ( anObj->FindAttribute( aGAttr, "AttributeFlags" ) ) + { + SALOMEDS::AttributeFlags_var anAttr = SALOMEDS::AttributeFlags::_narrow( aGAttr ); + anAttr->Set( theFlag, theValue ); + } + else if ( theValue ) + { + SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder(); + SALOMEDS::AttributeFlags_var anAttr = SALOMEDS::AttributeFlags::_narrow( + aBuilder->FindOrCreateAttribute( anObj, "AttributeFlags" ) ); + anAttr->Set( theFlag, theValue ); + } + return true; + } + + return false; +} + +//======================================================================= +// name : getAllChildren +// Purpose : Get all children of object. +// If theObj is null all objects of study are returned +//======================================================================= +void SALOMEDS_Tool::GetAllChildren( SALOMEDS::Study_var theStudy, + SALOMEDS::SObject_var theObj, + std::list& theList ) +{ + if ( theObj->_is_nil() ) + { + SALOMEDS::SComponentIterator_var anIter = theStudy->NewComponentIterator(); + for ( ; anIter->More(); anIter->Next() ) + { + SALOMEDS::SObject_var anObj = SALOMEDS::SObject::_narrow( anIter->Value() ); + if ( !anObj->_is_nil() ) + { + theList.push_back( anObj ); + GetAllChildren( theStudy, anObj, theList ); + } + } + } + else + { + SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator( theObj ); + for ( ; anIter->More(); anIter->Next() ) + { + SALOMEDS::SObject_var anObj = anIter->Value(); + SALOMEDS::SObject_var aRef; + if ( !anObj->ReferencedObject( aRef ) ) + { + theList.push_back( anObj ); + GetAllChildren( theStudy, anObj, theList ); + } + } + } +} + + + + + + + + + + + diff --git a/src/TOOLSDS/SALOMEDS_Tool.hxx b/src/TOOLSDS/SALOMEDS_Tool.hxx index fed29bf55..ecc4df6bc 100644 --- a/src/TOOLSDS/SALOMEDS_Tool.hxx +++ b/src/TOOLSDS/SALOMEDS_Tool.hxx @@ -10,7 +10,8 @@ #ifndef __SALOMEDS_Tool_H__ #define __SALOMEDS_Tool_H__ -#include +#include +#include // IDL headers #include "SALOMEconfig.h" @@ -50,5 +51,41 @@ public: // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "/tmp/aaa" static std::string GetDirFromPath(const char* thePath); + // Retrieves specified flaf from "AttributeFlags" attribute + static bool GetFlag( const int theFlag, + SALOMEDS::Study_var theStudy, + SALOMEDS::SObject_var theObj ); + + // Sets/Unsets specified flaf from "AttributeFlags" attribute + static bool SetFlag( const int theFlag, + SALOMEDS::Study_var theStudy, + const char* theEntry, + const bool theValue ); + + // Get all children of object. If theObj is null all objects of study are returned + static void GetAllChildren( SALOMEDS::Study_var theStudy, + SALOMEDS::SObject_var theObj, + std::list& theList ); + }; #endif + + + + + + + + + + + + + + + + + + + + diff --git a/src/TOOLSGUI/Makefile.in b/src/TOOLSGUI/Makefile.in index 03a986861..73a914c7f 100644 --- a/src/TOOLSGUI/Makefile.in +++ b/src/TOOLSGUI/Makefile.in @@ -35,7 +35,7 @@ VPATH=.:@srcdir@:@top_srcdir@/idl @COMMENCE@ # header files -EXPORT_HEADERS= +EXPORT_HEADERS = ToolsGUI.h # .po files to transform in .qm PO_FILES = \ @@ -48,10 +48,10 @@ LIB = libToolsGUI.la LIB_SRC = ToolsGUI.cxx \ ToolsGUI_CatalogGeneratorDlg.cxx -LIB_MOC = ToolsGUI_moc.cxx \ - ToolsGUI_CatalogGeneratorDlg_moc.cxx +LIB_MOC = ToolsGUI_CatalogGeneratorDlg_moc.cxx -LIB_CLIENT_IDL = SALOME_Exception.idl +LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl \ + SALOME_Component.idl SALOME_Exception.idl # additionnal information to compil and link file diff --git a/src/TOOLSGUI/ToolsGUI.cxx b/src/TOOLSGUI/ToolsGUI.cxx index 7e98ad7b1..eb0b26b85 100644 --- a/src/TOOLSGUI/ToolsGUI.cxx +++ b/src/TOOLSGUI/ToolsGUI.cxx @@ -32,48 +32,112 @@ #include "utilities.h" #include + +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + using namespace std; +//============================================================================ +// function : runCommand +// purpose : Run command +//============================================================================ int ToolsGUI::runCommand(string & arg) { int res; - res = system(arg.c_str()); + res = system( arg.c_str() ); - if (res == -1) - MESSAGE("fork failed (system command result = 0x" << hex << res << ")" << dec) + if ( res == -1 ) + MESSAGE( "fork failed (system command result = 0x" << hex << res << ")" << dec ) else - if (res == 217) - MESSAGE("shell exec failed (system command result = 0x" << hex << res << ")" << dec) - + if ( res == 217 ) + MESSAGE( "shell exec failed (system command result = 0x" << hex << res << ")" << dec ) return res; } -bool ToolsGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +//============================================================================ +// function : OnGUIEvent +// purpose : Process events +//============================================================================ +bool ToolsGUI::OnGUIEvent( int theCommandID, QAD_Desktop* parent ) { - QAD_Study* myActiveStudy = parent->getActiveStudy(); - switch (theCommandID) + switch ( theCommandID ) + { + case 5102 : { - case 5102 : - { - ToolsGUI_CatalogGeneratorDlg* aDlg = new ToolsGUI_CatalogGeneratorDlg(parent); - aDlg->exec(); - delete aDlg; - break; - } - - default: - MESSAGE (" No command associated with this id = " << theCommandID ) + ToolsGUI_CatalogGeneratorDlg* aDlg = new ToolsGUI_CatalogGeneratorDlg( parent ); + aDlg->exec(); + delete aDlg; break; } + + default: + MESSAGE ( " No command associated with this id = " << theCommandID ) + break; + } return true; } extern "C" { - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) + bool OnGUIEvent( int theCommandID, QAD_Desktop* parent ) { - //MESSAGE("ToolsGUI::OnGUIEvent "<< theCommandID); return ToolsGUI::OnGUIEvent(theCommandID, parent); } +} + +//======================================================================= +// name : GetVisibility +// Purpose : Verify whether object is visible or not +//======================================================================= +bool ToolsGUI::GetVisibility( SALOMEDS::Study_var theStudy, + SALOMEDS::SObject_var theObj, + void* theId ) +{ + SALOMEDS::GenericAttribute_var anAttr; + if ( !theObj->_is_nil() && theObj->FindAttribute( anAttr, "AttributeGraphic" ) ) + { + SALOMEDS::AttributeGraphic_var aGraphic = + SALOMEDS::AttributeGraphic::_narrow( anAttr ); + return aGraphic->GetVisibility( (unsigned long)theId ); + } + return false; } + +//======================================================================= +// name : SetVisibility +// Purpose : Set flag visibility of object +//======================================================================= +bool ToolsGUI::SetVisibility( SALOMEDS::Study_var theStudy, + const char* theEntry, + const bool theValue, + void* theId ) +{ + SALOMEDS::SObject_var anObj = theStudy->FindObjectID( theEntry ); + + if ( !anObj->_is_nil() ) + { + SALOMEDS::GenericAttribute_var aGAttr; + if ( anObj->FindAttribute( aGAttr, "AttributeGraphic" ) ) + { + SALOMEDS::AttributeGraphic_var anAttr = SALOMEDS::AttributeGraphic::_narrow( aGAttr ); + anAttr->SetVisibility( (unsigned long)theId, theValue ); + } + else if ( theValue ) + { + SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder(); + SALOMEDS::AttributeGraphic_var anAttr = SALOMEDS::AttributeGraphic::_narrow( + aBuilder->FindOrCreateAttribute( anObj, "AttributeGraphic" ) ); + anAttr->SetVisibility( (unsigned long)theId, theValue ); + } + return true; + } + + return false; +} + + + + + + diff --git a/src/TOOLSGUI/ToolsGUI.h b/src/TOOLSGUI/ToolsGUI.h index 93f697881..bd4022f22 100644 --- a/src/TOOLSGUI/ToolsGUI.h +++ b/src/TOOLSGUI/ToolsGUI.h @@ -35,36 +35,24 @@ #include "QAD_Desktop.h" -class ToolsGUI : public QObject +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +class Standard_EXPORT ToolsGUI { - Q_OBJECT public : -// Methods PUBLIC -// - Standard_EXPORT static int ToolsGUI::runCommand(string & arg); -Standard_EXPORT static bool OnGUIEvent (int theCommandID, QAD_Desktop* parent); - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // + static int runCommand( string& ); + static bool OnGUIEvent( int theCommandID, QAD_Desktop* parent ); + static bool GetVisibility( SALOMEDS::Study_var theStudy, + SALOMEDS::SObject_var theObj, + void* theId ); + static bool SetVisibility( SALOMEDS::Study_var theStudy, + const char* theEntry, + const bool theValue, + void* theId ); }; #endif -- 2.39.2