From 5df4a45998e93372762d3ebf5e2ab3a96ff33840 Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 29 Jul 2015 15:09:44 +0300 Subject: [PATCH] Properly wrap code related to OCCviewer, Plot2dViewer, PVViewer in the SalomePyQt interface. --- adm_local/cmake_files/UsePyQt4.cmake | 22 +- src/SALOME_PYQT/CMakeLists.txt | 4 +- src/SALOME_PYQT/SalomePyQt/CMakeLists.txt | 19 +- src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx | 727 +++++++++--------- src/SALOME_PYQT/SalomePyQt/SalomePyQt.h | 10 + src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip | 91 +-- .../SalomePyQt/SalomePyQt_Plot2d.sip | 111 +++ 7 files changed, 516 insertions(+), 468 deletions(-) create mode 100644 src/SALOME_PYQT/SalomePyQt/SalomePyQt_Plot2d.sip diff --git a/adm_local/cmake_files/UsePyQt4.cmake b/adm_local/cmake_files/UsePyQt4.cmake index bad5488ac..ee3ec4558 100644 --- a/adm_local/cmake_files/UsePyQt4.cmake +++ b/adm_local/cmake_files/UsePyQt4.cmake @@ -124,17 +124,26 @@ ENDMACRO(PYQT4_WRAP_UIC) # - Output files are generated in the current build directory. # - This version of macro requires class(es) definition in the # *.sip file to be started on a new line without any preceeding characters. +# +# WARNING: +# - The macro does not properly processes sip features which are wrapped +# with sip conditionals. +# - The macro works only if one single sip module is processed +# (there's only one %Module directive within all input sip files). # # TODO: # - Check if dependency of static sources on generated headers works properly: # if header is changed, dependant sources should be recompiled. +# - Think how to properly process sip conditionals. +# - Process several sip modules. # #################################################################### MACRO(PYQT4_WRAP_SIP outfiles) + SET(_output) + SET(_module_input) FOREACH(_input ${ARGN}) FILE(STRINGS ${_input} _sip_modules REGEX "%Module") FILE(STRINGS ${_input} _sip_classes REGEX "^class ") - SET(_output) FOREACH(_sip_module ${_sip_modules}) STRING(REGEX MATCH ".*%Module *\\( *name=.*\\).*" _mod_name "${_sip_module}") IF (_mod_name) @@ -146,6 +155,7 @@ MACRO(PYQT4_WRAP_SIP outfiles) SET(_mod_source "sip${_mod_name}cmodule${PYQT_CXX_EXT}") LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/${_mod_source}) SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/${_mod_source}) + SET(_module_input ${_input}) ENDFOREACH() FOREACH(_sip_class ${_sip_classes}) STRING(REGEX MATCH ".*class +.* *:" _class_name "${_sip_class}") @@ -159,12 +169,12 @@ MACRO(PYQT4_WRAP_SIP outfiles) LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/${_class_source}) SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/${_class_source}) ENDFOREACH() - ADD_CUSTOM_COMMAND( - OUTPUT ${_output} - COMMAND ${SIP_EXECUTABLE} ${PYQT_SIPFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${_input} - MAIN_DEPENDENCY ${_input} - ) ENDFOREACH() + ADD_CUSTOM_COMMAND( + OUTPUT ${_output} + COMMAND ${SIP_EXECUTABLE} ${PYQT_SIPFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${_module_input} + MAIN_DEPENDENCY ${_module_input} + ) ENDMACRO(PYQT4_WRAP_SIP) diff --git a/src/SALOME_PYQT/CMakeLists.txt b/src/SALOME_PYQT/CMakeLists.txt index c4f6e0775..c9aa978f3 100755 --- a/src/SALOME_PYQT/CMakeLists.txt +++ b/src/SALOME_PYQT/CMakeLists.txt @@ -18,10 +18,8 @@ # ADD_SUBDIRECTORY(SALOME_PYQT_GUILight) +ADD_SUBDIRECTORY(SalomePyQt) -IF(SALOME_USE_PLOT2DVIEWER) - ADD_SUBDIRECTORY(SalomePyQt) -ENDIF() IF(NOT SALOME_LIGHT_ONLY) ADD_SUBDIRECTORY(SALOME_PYQT_GUI) ENDIF(NOT SALOME_LIGHT_ONLY) diff --git a/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt b/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt index 21dbb3eb2..e77ddf6ae 100755 --- a/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt +++ b/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt @@ -38,10 +38,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/LightApp ${PROJECT_SOURCE_DIR}/src/LogWindow ${PROJECT_SOURCE_DIR}/src/OBJECT - ${PROJECT_SOURCE_DIR}/src/OCCViewer - ${PROJECT_SOURCE_DIR}/src/PVViewer ${PROJECT_SOURCE_DIR}/src/ObjBrowser - ${PROJECT_SOURCE_DIR}/src/Plot2d ${PROJECT_SOURCE_DIR}/src/PyInterp ${PROJECT_SOURCE_DIR}/src/PyConsole ${PROJECT_SOURCE_DIR}/src/Qtx @@ -50,6 +47,19 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/SUIT ) +IF(SALOME_USE_OCCVIEWER) + INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/OCCViewer) +ENDIF(SALOME_USE_OCCVIEWER) +IF(SALOME_USE_PVVIEWER) + INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/PVViewer) +ENDIF(SALOME_USE_PVVIEWER) +IF(SALOME_USE_PLOT2DVIEWER) + INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Plot2d) +ELSE(SALOME_USE_PLOT2DVIEWER) + #disable 'ENABLE_PLOT2D' feature + SET(PYQT_SIPFLAGS ${PYQT_SIPFLAGS} "-xENABLE_PLOT2D;") +ENDIF(SALOME_USE_PLOT2DVIEWER) + IF(SALOME_LIGHT_ONLY) #disable 'ENABLE_CORBA' feature SET(PYQT_SIPFLAGS ${PYQT_SIPFLAGS} "-xENABLE_CORBA;") @@ -87,6 +97,9 @@ SET(_moc_HEADERS SalomePyQt.h) # sip files / to be processed by sip SET(_sip_files SalomePyQt.sip) +IF(SALOME_USE_PLOT2DVIEWER) + LIST(APPEND _sip_files SalomePyQt_Plot2d.sip) +ENDIF(SALOME_USE_PLOT2DVIEWER) # --- sources --- diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index 39b6e8113..42e812425 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -38,12 +38,18 @@ #include "LightApp_SelectionMgr.h" #include "LogWindow.h" +#ifndef DISABLE_OCCVIEWER #include "OCCViewer_ViewWindow.h" #include "OCCViewer_ViewFrame.h" +#endif // DISABLE_OCCVIEWER +#ifndef DISABLE_PLOT2DVIEWER #include "Plot2d_ViewManager.h" #include "Plot2d_ViewWindow.h" +#endif // DISABLE_PLOT2DVIEWER +#ifndef DISABLE_PVVIEWER #include "PVViewer_ViewManager.h" #include "PVViewer_ViewModel.h" +#endif // DISABLE_PVVIEWER #include "QtxActionMenuMgr.h" #include "QtxWorkstack.h" #include "QtxTreeView.h" @@ -53,6 +59,8 @@ #include "SUIT_ResourceMgr.h" #include "SUIT_Session.h" #include "SUIT_Tools.h" +#include "SUIT_ViewManager.h" +#include "SUIT_ViewWindow.h" #include "PyConsole_Console.h" #include @@ -60,75 +68,156 @@ #include #include -/*! - \brief Get the currently active application. - \internal - \return active application object or 0 if there is no any -*/ -static LightApp_Application* getApplication() +namespace { - if ( SUIT_Session::session() ) - return dynamic_cast( SUIT_Session::session()->activeApplication() ); - return 0; -} + /*! + \brief Get the currently active application. + \internal + \return active application object or 0 if there is no any + */ + LightApp_Application* getApplication() + { + if ( SUIT_Session::session() ) + return dynamic_cast( SUIT_Session::session()->activeApplication() ); + return 0; + } + + /*! + \brief Get the currently active study. + \internal + \return active study or 0 if there is no study opened + */ + LightApp_Study* getActiveStudy() + { + if ( getApplication() ) + return dynamic_cast( getApplication()->activeStudy() ); + return 0; + } -/*! - \brief Get the currently active study. - \internal - \return active study or 0 if there is no study opened -*/ -static LightApp_Study* getActiveStudy() -{ - if ( getApplication() ) - return dynamic_cast( getApplication()->activeStudy() ); - return 0; -} + /*! + \brief Get the currently active module. + \internal + This function returns correct result only if Python-based + module is currently active. Otherwize, 0 is returned. + */ + LightApp_Module* getActiveModule() + { + LightApp_Module* module = 0; + if ( LightApp_Application* anApp = getApplication() ) { + module = PyModuleHelper::getInitModule(); + if ( !module ) + module = dynamic_cast( anApp->activeModule() ); + } + return module; + } + + /*! + \brief Get the currently active Python module's helper. + \internal + This function returns correct result only if Python-based + module is currently active. Otherwize, 0 is returned. + */ + PyModuleHelper* getPythonHelper() + { + LightApp_Module* module = getActiveModule(); + PyModuleHelper* helper = module ? qFindChild( module, "python_module_helper" ) : 0; + return helper; + } + + /*! + \brief Get SALOME verbose level + \internal + \return \c true if SALOME debug output is allowed or \c false otherwise + */ + bool verbose() + { + bool isVerbose = false; + if ( getenv( "SALOME_VERBOSE" ) ) { + QString envVar = getenv( "SALOME_VERBOSE" ); + bool ok; + int value = envVar.toInt( &ok ); + isVerbose = ok && value != 0; + } + return isVerbose; + } + + /*! + \brief Get menu item title + \internal + \param menuId menu identifier + \return menu title (localized) + */ + QString getMenuName( const QString& menuId ) + { + QStringList contexts; + contexts << "SalomeApp_Application" << "LightApp_Application" << "STD_TabDesktop" << + "STD_MDIDesktop" << "STD_Application" << "SUIT_Application" << ""; + QString menuName = menuId; + for ( int i = 0; i < contexts.count() && menuName == menuId; i++ ) + menuName = QApplication::translate( contexts[i].toLatin1().data(), menuId.toLatin1().data() ); + return menuName; + } + + /*! + \brief Load module icon + \internal + \param module module name + \param fileName path to the icon file + \return icon + */ + QIcon loadIconInternal( const QString& module, const QString& fileName ) + { + QIcon icon; + + LightApp_Application* app = getApplication(); + + if ( app && !fileName.isEmpty() ) { + QPixmap pixmap = app->resourceMgr()->loadPixmap( module, + QApplication::translate( module.toLatin1().data(), + fileName.toLatin1().data() ) ); + if ( !pixmap.isNull() ) + icon = QIcon( pixmap ); + } + return icon; + } -/*! - \brief Get the currently active module. - \internal - This function returns correct result only if Python-based - module is currently active. Otherwize, 0 is returned. -*/ -static LightApp_Module* getActiveModule() -{ - LightApp_Module* module = 0; - if ( LightApp_Application* anApp = getApplication() ) { - module = PyModuleHelper::getInitModule(); - if ( !module ) - module = dynamic_cast( anApp->activeModule() ); + /*! + \brief Gets window with specified identifier + \internal + \param id window identifier + \return pointer on the window + */ + SUIT_ViewWindow* getWnd( const int id ) + { + SUIT_ViewWindow* resWnd = 0; + + LightApp_Application* app = getApplication(); + if ( app ) { + ViewManagerList vmlist = app->viewManagers(); + foreach( SUIT_ViewManager* vm, vmlist ) { + QVector vwlist = vm->getViews(); + foreach ( SUIT_ViewWindow* vw, vwlist ) { + if ( id == vw->getId() ) { + resWnd = vw; + break; + } + } + } + } + return resWnd; } - return module; -} -/*! - \brief Get the currently active Python module's helper. - \internal - This function returns correct result only if Python-based - module is currently active. Otherwize, 0 is returned. -*/ -static PyModuleHelper* getPythonHelper() -{ - LightApp_Module* module = getActiveModule(); - PyModuleHelper* helper = module ? qFindChild( module, "python_module_helper" ) : 0; - return helper; -} + /*! + \brief Map of created selection objects. + \internal + */ + QMap SelMap; -/*! - \brief Get SALOME verbose level - \internal - \return \c true if SALOME debug output is allowed or \c false otherwise -*/ -static bool verbose() -{ - bool isVerbose = false; - if ( getenv( "SALOME_VERBOSE" ) ) { - QString envVar = getenv( "SALOME_VERBOSE" ); - bool ok; - int value = envVar.toInt( &ok ); - isVerbose = ok && value != 0; - } - return isVerbose; + /*! + \brief Default resource file section name. + \internal + */ + const char* DEFAULT_SECTION = "SalomePyQt"; } /*! @@ -136,12 +225,6 @@ static bool verbose() \brief The class represents selection which can be used in Python. */ -/*! - \brief Map of created selection objects. - \internal -*/ -static QMap SelMap; - /*! \brief Get the selection object for the specified application. @@ -376,23 +459,6 @@ public: } }; -/*! - \brief Get menu item title - \internal - \param menuId menu identifier - \return menu title (localized) -*/ -static QString getMenuName( const QString& menuId ) -{ - QStringList contexts; - contexts << "SalomeApp_Application" << "LightApp_Application" << "STD_TabDesktop" << - "STD_MDIDesktop" << "STD_Application" << "SUIT_Application" << ""; - QString menuName = menuId; - for ( int i = 0; i < contexts.count() && menuName == menuId; i++ ) - menuName = QApplication::translate( contexts[i].toLatin1().data(), menuId.toLatin1().data() ); - return menuName; -} - QMenu* SalomePyQt::getPopupMenu( const MenuName menu ) { QString menuName; @@ -723,12 +789,6 @@ void SalomePyQt::setModified( bool flag ) ProcessVoidEvent( new TEvent( flag ) ); } -/*! - \brief Default resource file section name. - \internal -*/ -static const char* DEFAULT_SECTION = "SalomePyQt"; - /*! \brief Add string setting to the application preferences. @@ -1464,22 +1524,6 @@ QString SalomePyQt::getExistingDirectory( QWidget* parent, \return icon object */ -static QIcon loadIconInternal( const QString& module, const QString& fileName ) -{ - QIcon icon; - - LightApp_Application* app = getApplication(); - - if ( app && !fileName.isEmpty() ) { - QPixmap pixmap = app->resourceMgr()->loadPixmap( module, - QApplication::translate( module.toLatin1().data(), - fileName.toLatin1().data() ) ); - if ( !pixmap.isNull() ) - icon = QIcon( pixmap ); - } - return icon; -} - class TLoadIconEvent: public SALOME_Event { public: @@ -2268,37 +2312,6 @@ void SalomePyQt::clearMessages() ProcessVoidEvent( new TEvent() ); } -/*! - \brief Gets window with specified identifier - \internal - \param id window identifier - \return pointer on the window -*/ -static SUIT_ViewWindow* getWnd( const int id ) -{ - SUIT_ViewWindow* resWnd = 0; - - LightApp_Application* app = getApplication(); - if ( app ) - { - ViewManagerList vmlist = app->viewManagers(); - foreach( SUIT_ViewManager* vm, vmlist ) - { - QVector vwlist = vm->getViews(); - foreach ( SUIT_ViewWindow* vw, vwlist ) - { - if ( id == vw->getId() ) - { - resWnd = vw; - break; - } - } - } - } - - return resWnd; -} - /*! \fn bool SalomePyQt::dumpView( const QString& filename, const int id = 0 ); \brief Dump the contents of the id view window. If id is 0 then current active view is processed. @@ -2320,45 +2333,41 @@ public: QString myFileName; int myWndId; TDumpViewEvent( const QString& filename, const int id ) - : myResult ( false ), myFileName( filename ), myWndId(id) {} + : myResult ( false ), myFileName( filename ), myWndId( id ) {} virtual void Execute() { - SUIT_ViewWindow* wnd = NULL; - if(myWndId == 0) - { + SUIT_ViewWindow* wnd = 0; + if ( !myWndId ) { if ( LightApp_Application* anApp = getApplication() ) { - SUIT_ViewManager* vm = anApp->activeViewManager(); - if ( vm ) - wnd = vm->getActiveView(); - } + SUIT_ViewManager* vm = anApp->activeViewManager(); + if ( vm ) + wnd = vm->getActiveView(); + } myWndId = wnd->getId(); - } - else - { - wnd = dynamic_cast(getWnd( myWndId )); - } + } + else { + wnd = dynamic_cast( getWnd( myWndId ) ); + } if ( wnd ) { QString fmt = SUIT_Tools::extension( myFileName ).toUpper(); - Plot2d_ViewWindow* wnd2D = dynamic_cast(wnd); - if(fmt == "PS" || fmt == "EPS" || fmt == "PDF") { - if(wnd2D) { - myResult = wnd2D->getViewFrame()->print(myFileName, fmt); - } else { - myResult = false; - } - } else { - if(wnd2D) { - qApp->postEvent( wnd2D->getViewFrame(), new QPaintEvent( QRect( 0, 0, wnd2D->getViewFrame()->width(), wnd2D->getViewFrame()->height() ) ) ); - qApp->postEvent( wnd2D, new QPaintEvent( QRect( 0, 0, wnd2D->width(), wnd2D->height() ) ) ); - qApp->processEvents(); - } - QImage im = wnd->dumpView(); - if ( !im.isNull() && !myFileName.isEmpty() ) { - if ( fmt.isEmpty() ) fmt = QString( "BMP" ); // default format - if ( fmt == "JPG" ) fmt = "JPEG"; - myResult = im.save( myFileName, fmt.toLatin1() ); +#ifndef DISABLE_PLOT2DVIEWER + Plot2d_ViewWindow* wnd2D = dynamic_cast( wnd ); + if ( wnd2D ) { + qApp->postEvent( wnd2D->getViewFrame(), new QPaintEvent( QRect( 0, 0, wnd2D->getViewFrame()->width(), wnd2D->getViewFrame()->height() ) ) ); + qApp->postEvent( wnd2D, new QPaintEvent( QRect( 0, 0, wnd2D->width(), wnd2D->height() ) ) ); + qApp->processEvents(); + if ( fmt == "PS" || fmt == "EPS" || fmt == "PDF" ) { + myResult = wnd2D->getViewFrame()->print( myFileName, fmt ); + return; } } +#endif // DISABLE_PLOT2DVIEWER + QImage im = wnd->dumpView(); + if ( !im.isNull() && !myFileName.isEmpty() ) { + if ( fmt.isEmpty() ) fmt = QString( "BMP" ); // default format + if ( fmt == "JPG" ) fmt = "JPEG"; + myResult = im.save( myFileName, fmt.toLatin1() ); + } } } }; @@ -2367,7 +2376,6 @@ bool SalomePyQt::dumpView( const QString& filename, const int id ) return ProcessEvent( new TDumpViewEvent( filename, id ) ); } - /*! \fn QList SalomePyQt::getViews(); \brief Get list of integer identifiers of all the currently opened views @@ -2384,11 +2392,9 @@ public: { myResult.clear(); LightApp_Application* app = getApplication(); - if ( app ) - { + if ( app ) { STD_TabDesktop* tabDesk = dynamic_cast( app->desktop() ); - if ( tabDesk ) - { + if ( tabDesk ) { QList wndlist = tabDesk->windows(); SUIT_ViewWindow* wnd; foreach ( wnd, wndlist ) @@ -2418,11 +2424,9 @@ public: virtual void Execute() { LightApp_Application* app = getApplication(); - if ( app ) - { + if ( app ) { SUIT_ViewManager* viewMgr = app->activeViewManager(); - if ( viewMgr ) - { + if ( viewMgr ) { SUIT_ViewWindow* wnd = viewMgr->getActiveView(); if ( wnd ) myResult = wnd->getId(); @@ -2453,8 +2457,7 @@ public: virtual void Execute() { SUIT_ViewWindow* wnd = getWnd( myWndId ); - if ( wnd ) - { + if ( wnd ) { SUIT_ViewManager* viewMgr = wnd->getViewManager(); if ( viewMgr ) myResult = viewMgr->getType(); @@ -2488,8 +2491,7 @@ public: virtual void Execute() { SUIT_ViewWindow* wnd = getWnd( myWndId ); - if ( wnd ) - { + if ( wnd ) { wnd->setWindowTitle( myTitle ); myResult = true; } @@ -2540,6 +2542,7 @@ public: if ( viewMgr ) { QString type = viewMgr->getType(); if ( type == "OCCViewer") { +#ifndef DISABLE_OCCVIEWER // specific processing for OCC viewer: // OCC view can embed up to 4 sub-views, split according to the specified layout; // - if there is only one sub-view active; it will be resized; @@ -2551,8 +2554,10 @@ public: myResult = true; } } +#endif // DISABLE_OCCVIEWER } else if ( type == "ParaView") { +#ifndef DISABLE_PVVIEWER // specific processing for ParaView viewer: // hierarchy of ParaView viewer is much complex than for usual view; // we look for sub-widget named "Viewport" @@ -2561,6 +2566,7 @@ public: lst[0]->resize( myWndWidth, myWndHeight ); myResult = true; } +#endif // DISABLE_PVVIEWER } else { if ( wnd->centralWidget() ) { @@ -2624,16 +2630,13 @@ public: { myResult.clear(); LightApp_Application* app = getApplication(); - if ( app ) - { + if ( app ) { ViewManagerList vmList; app->viewManagers( myType, vmList ); SUIT_ViewManager* viewMgr; - foreach ( viewMgr, vmList ) - { + foreach ( viewMgr, vmList ) { QVector vec = viewMgr->getViews(); - for ( int i = 0, n = vec.size(); i < n; i++ ) - { + for ( int i = 0, n = vec.size(); i < n; i++ ) { SUIT_ViewWindow* wnd = vec[ i ]; if ( wnd ) myResult.append( wnd->getId() ); @@ -2666,8 +2669,7 @@ public: virtual void Execute() { SUIT_ViewWindow* wnd = getWnd( myWndId ); - if ( wnd ) - { + if ( wnd ) { wnd->setFocus(); myResult = true; } @@ -2706,30 +2708,27 @@ public: virtual void Execute() { LightApp_Application* app = getApplication(); - if ( app ) - { - SUIT_ViewManager* viewMgr = app->createViewManager( myType ); - if ( viewMgr ) - { - SUIT_ViewWindow* wnd = viewMgr->getActiveView(); - if ( wnd ) { - wnd->setShown(myVisible); - if(!myVisible && myWidth == 0 && myHeight == 0) { - myWidth = 1024; - myHeight = 768; - } - if(myWidth > 0 && myHeight > 0) { - Plot2d_ViewWindow* wnd2D = dynamic_cast(wnd); - if(wnd2D) { - wnd2D->getViewFrame()->setGeometry(0,0,myWidth,myHeight); - } else { - wnd->setGeometry(0,0,myWidth,myHeight); - } - } - myResult = wnd->getId(); - } + if ( app ) { + SUIT_ViewManager* viewMgr = app->createViewManager( myType ); + if ( viewMgr ) { + QWidget* wnd = viewMgr->getActiveView(); + myResult = viewMgr->getActiveView()->getId(); + if ( wnd ) { + wnd->setShown(myVisible); + if ( !myVisible && myWidth == 0 && myHeight == 0 ) { + myWidth = 1024; + myHeight = 768; + } + if (myWidth > 0 && myHeight > 0) { +#ifndef DISABLE_PLOT2DVIEWER + Plot2d_ViewWindow* wnd2D = dynamic_cast( wnd ); + if ( wnd2D ) wnd = wnd2D->getViewFrame(); +#endif // DISABLE_PLOT2DVIEWER + wnd->setGeometry( 0, 0, myWidth, myHeight ); } + } } + } } }; int SalomePyQt::createView( const QString& type, bool visible, const int width, const int height ) @@ -2761,11 +2760,9 @@ public: virtual void Execute() { LightApp_Application* app = getApplication(); - if ( app ) - { + if ( app ) { SUIT_ViewManager* viewMgr = app->createViewManager( myType, myWidget ); - if ( viewMgr ) - { + if ( viewMgr ) { SUIT_ViewWindow* wnd = viewMgr->getActiveView(); if ( wnd ) myResult = wnd->getId(); @@ -2799,11 +2796,9 @@ public: virtual void Execute() { SUIT_ViewWindow* wnd = getWnd( myWndId ); - if ( wnd ) - { + if ( wnd ) { SUIT_ViewManager* viewMgr = wnd->getViewManager(); - if ( viewMgr ) - { + if ( viewMgr ) { wnd->close(); myResult = true; } @@ -2834,30 +2829,28 @@ public: virtual void Execute() { SUIT_ViewWindow* wnd = getWnd( myWndId ); - if ( wnd ) - { + if ( wnd ) { SUIT_ViewManager* viewMgr = wnd->getViewManager(); - if ( viewMgr ) - { - if ( wnd->inherits( "OCCViewer_ViewWindow" ) ) - { + if ( viewMgr ) { +#ifndef DISABLE_OCCVIEWER + if ( wnd->inherits( "OCCViewer_ViewWindow" ) ) { OCCViewer_ViewWindow* occView = (OCCViewer_ViewWindow*)( wnd ); occView->onCloneView(); - wnd = viewMgr->getActiveView(); if ( wnd ) myResult = wnd->getId(); } - else if ( wnd->inherits( "Plot2d_ViewWindow" ) ) - { +#endif // DISABLE_OCCVIEWER +#ifndef DISABLE_PLOT2DVIEWER + if ( wnd->inherits( "Plot2d_ViewWindow" ) ) { Plot2d_ViewManager* viewMgr2d = dynamic_cast( viewMgr ); Plot2d_ViewWindow* srcWnd2d = dynamic_cast( wnd ); - if ( viewMgr2d && srcWnd2d ) - { + if ( viewMgr2d && srcWnd2d ) { Plot2d_ViewWindow* resWnd = viewMgr2d->cloneView( srcWnd2d ); myResult = resWnd->getId(); } } +#endif // DISABLE_OCCVIEWER } } } @@ -2994,14 +2987,11 @@ public: virtual void Execute() { LightApp_Application* app = getApplication(); - if ( app ) - { + if ( app ) { STD_TabDesktop* tabDesk = dynamic_cast( app->desktop() ); - if ( tabDesk ) - { + if ( tabDesk ) { QtxWorkstack* wStack = tabDesk->workstack(); - if ( wStack ) - { + if ( wStack ) { wStack->stack(); myResult = true; } @@ -3041,21 +3031,17 @@ public: virtual void Execute() { SUIT_ViewWindow* wnd = getWnd( myWndId ); - if ( wnd ) - { + if ( wnd ) { // activate view // wnd->setFocus(); ??? // split workstack - if ( getApplication() ) - { + if ( getApplication() ) { STD_TabDesktop* desk = dynamic_cast( getApplication()->desktop() ); - if ( desk ) - { + if ( desk ) { QtxWorkstack* wStack = desk->workstack(); - if ( wStack ) - { + if ( wStack ) { Qt::Orientation qtOri = ( myOri == Horizontal ) ? Qt::Horizontal : Qt::Vertical; @@ -3108,8 +3094,7 @@ public: { SUIT_ViewWindow* wnd = getWnd( myWndId ); SUIT_ViewWindow* wnd_to = getWnd( myWndToId ); - if ( wnd && wnd_to ) - { + if ( wnd && wnd_to ) { QtxWorkstack* wStack = dynamic_cast( getApplication()->desktop() )->workstack(); if ( wStack ) @@ -3142,16 +3127,13 @@ public: { myResult.clear(); SUIT_ViewWindow* wnd = getWnd( myWndId ); - if ( wnd ) - { + if ( wnd ) { QtxWorkstack* wStack = dynamic_cast( getApplication()->desktop() )->workstack(); - if ( wStack ) - { + if ( wStack ) { QWidgetList wgList = wStack->windowList( wnd ); QWidget* wg; - foreach ( wg, wgList ) - { + foreach ( wg, wgList ) { SUIT_ViewWindow* tmpWnd = dynamic_cast( wg ); if ( tmpWnd && tmpWnd != wnd ) myResult.append( tmpWnd->getId() ); @@ -3624,6 +3606,8 @@ QStringList SalomePyQt::getChildren( const QString& entry, const bool recursive return ProcessEvent( new TGetChildrenEvent( entry, recursive ) ); } +#ifndef DISABLE_PLOT2DVIEWER +// Next set of methods relates to the Plot2d viewer functionality /*! \fn void SalomePyQt::displayCurve( const int id, Plot2d_Curve* theCurve ) @@ -3637,18 +3621,16 @@ class TDisplayCurve: public SALOME_Event public: int myWndId; Plot2d_Curve* myCurve; - TDisplayCurve(const int id, Plot2d_Curve* theCurve) : myWndId(id), myCurve(theCurve) {} + TDisplayCurve( const int id, Plot2d_Curve* theCurve ) : myWndId( id ), myCurve( theCurve ) {} virtual void Execute() { - Plot2d_ViewWindow* wnd = dynamic_cast(getWnd( myWndId )); - if ( wnd ) - { - wnd->getViewFrame()->displayCurve(myCurve); - } + Plot2d_ViewWindow* wnd = dynamic_cast( getWnd( myWndId ) ); + if ( wnd ) + wnd->getViewFrame()->displayCurve( myCurve ); } }; -void SalomePyQt::displayCurve(const int id, Plot2d_Curve* theCurve) +void SalomePyQt::displayCurve( const int id, Plot2d_Curve* theCurve ) { - ProcessVoidEvent( new TDisplayCurve(id, theCurve) ); + ProcessVoidEvent( new TDisplayCurve( id, theCurve ) ); } /*! @@ -3663,18 +3645,15 @@ class TEraseCurve: public SALOME_Event public: int myWndId; Plot2d_Curve* myCurve; - TEraseCurve(const int id, Plot2d_Curve* theCurve) : myWndId(id), myCurve(theCurve) {} + TEraseCurve( const int id, Plot2d_Curve* theCurve ) : myWndId( id ), myCurve( theCurve ) {} virtual void Execute() { - Plot2d_ViewWindow* wnd = dynamic_cast(getWnd( myWndId )); - if ( wnd ) - { - wnd->getViewFrame()->eraseCurve(myCurve); - } + Plot2d_ViewWindow* wnd = dynamic_cast( getWnd( myWndId ) ); + wnd->getViewFrame()->eraseCurve( myCurve ); } }; -void SalomePyQt::eraseCurve(const int id, Plot2d_Curve* theCurve) +void SalomePyQt::eraseCurve( const int id, Plot2d_Curve* theCurve ) { - ProcessVoidEvent( new TEraseCurve(id, theCurve) ); + ProcessVoidEvent( new TEraseCurve( id, theCurve ) ); } /*! @@ -3687,37 +3666,32 @@ class TDeleteCurve: public SALOME_Event { public: Plot2d_Curve* myCurve; - TDeleteCurve(Plot2d_Curve* theCurve) : myCurve(theCurve) {} + TDeleteCurve( Plot2d_Curve* theCurve ) : myCurve( theCurve ) {} virtual void Execute() { LightApp_Application* app = getApplication(); - if ( app ) - { + if ( app ) { STD_TabDesktop* tabDesk = dynamic_cast( app->desktop() ); - if ( tabDesk ) - { + if ( tabDesk ) { QList wndlist = tabDesk->windows(); SUIT_ViewWindow* wnd; - foreach ( wnd, wndlist ) - { - Plot2d_ViewWindow* aP2d = dynamic_cast(wnd); - if(aP2d) - { - aP2d->getViewFrame()->eraseObject(myCurve); - } + foreach ( wnd, wndlist ) { + Plot2d_ViewWindow* aP2d = dynamic_cast( wnd ); + if ( aP2d ) + aP2d->getViewFrame()->eraseObject( myCurve ); } } } } }; -void SalomePyQt::eraseCurve(Plot2d_Curve * theCurve) +void SalomePyQt::eraseCurve( Plot2d_Curve* theCurve ) { - ProcessVoidEvent( new TDeleteCurve(theCurve) ); + ProcessVoidEvent( new TDeleteCurve( theCurve ) ); } /*! \brief updateCurves (repaint) curves in view window. */ -void SalomePyQt::updateCurves(const int id) +void SalomePyQt::updateCurves( const int id ) { class TEvent: public SALOME_Event { @@ -3726,14 +3700,12 @@ void SalomePyQt::updateCurves(const int id) TEvent( const int id ) : myWndId( id ) {} virtual void Execute() { - Plot2d_ViewWindow* wnd = dynamic_cast(getWnd( myWndId )); + Plot2d_ViewWindow* wnd = dynamic_cast( getWnd( myWndId ) ); if ( wnd ) - { wnd->getViewFrame()->DisplayAll(); - } } }; - ProcessVoidEvent( new TEvent(id) ); + ProcessVoidEvent( new TEvent( id ) ); } /*! @@ -3752,19 +3724,17 @@ public: int myWndId; ObjectType myType; TGetPlot2dTitle(const int id, ObjectType type) : - myWndId(id), - myType(type) {} + myWndId( id ), + myType( type ) {} virtual void Execute() { - Plot2d_ViewWindow* wnd = dynamic_cast(getWnd( myWndId )); - if ( wnd ) - { - myResult = wnd->getViewFrame()->getTitle((Plot2d_ViewFrame::ObjectType)myType); - } + Plot2d_ViewWindow* wnd = dynamic_cast( getWnd( myWndId ) ); + if ( wnd ) + myResult = wnd->getViewFrame()->getTitle( (Plot2d_ViewFrame::ObjectType)myType ); } }; -QString SalomePyQt::getPlot2dTitle(const int id, ObjectType type) +QString SalomePyQt::getPlot2dTitle( const int id, ObjectType type ) { - return ProcessEvent( new TGetPlot2dTitle(id, type) ); + return ProcessEvent( new TGetPlot2dTitle( id, type ) ); } @@ -3785,22 +3755,19 @@ public: QString myTitle; ObjectType myType; bool myShow; - TSetPlot2dTitle(const int id, const QString& title, ObjectType type, bool show) : - myWndId(id), - myTitle(title), - myType(type), - myShow(show) {} + TSetPlot2dTitle( const int id, const QString& title, ObjectType type, bool show ) : + myWndId( id ), + myTitle( title ), + myType( type ), + myShow( show ) {} virtual void Execute() { - Plot2d_ViewWindow* wnd = dynamic_cast(getWnd( myWndId )); - if ( wnd ) - { - wnd->getViewFrame()->setTitle(myShow, myTitle, (Plot2d_ViewFrame::ObjectType)myType, false); - } + Plot2d_ViewWindow* wnd = dynamic_cast( getWnd( myWndId ) ); + wnd->getViewFrame()->setTitle( myShow, myTitle, (Plot2d_ViewFrame::ObjectType)myType, false ); } }; -void SalomePyQt::setPlot2dTitle(const int id, const QString& title, ObjectType type, bool show) +void SalomePyQt::setPlot2dTitle( const int id, const QString& title, ObjectType type, bool show ) { - ProcessVoidEvent( new TSetPlot2dTitle(id, title, type, show) ); + ProcessVoidEvent( new TSetPlot2dTitle( id, title, type, show ) ); } /*! @@ -3821,15 +3788,14 @@ public: virtual void Execute() { myResult.clear(); - Plot2d_ViewWindow* wnd = dynamic_cast(getWnd( myWndId )); - if ( wnd ) - { + Plot2d_ViewWindow* wnd = dynamic_cast( getWnd( myWndId ) ); + if ( wnd ) { double XMin, XMax, YMin, YMax, Y2Min, Y2Max; - wnd->getViewFrame()->getFitRangeByCurves(XMin, XMax, YMin, YMax, Y2Min, Y2Max); - myResult.append(XMin); - myResult.append(XMax); - myResult.append(YMin); - myResult.append(YMax); + wnd->getViewFrame()->getFitRangeByCurves( XMin, XMax, YMin, YMax, Y2Min, Y2Max ); + myResult.append( XMin ); + myResult.append( XMax ); + myResult.append( YMin ); + myResult.append( YMax ); } } }; @@ -3856,15 +3822,14 @@ public: virtual void Execute() { myResult.clear(); - Plot2d_ViewWindow* wnd = dynamic_cast(getWnd( myWndId )); - if ( wnd ) - { + Plot2d_ViewWindow* wnd = dynamic_cast( getWnd( myWndId ) ); + if ( wnd ) { double XMin, XMax, YMin, YMax, Y2Min, Y2Max; - wnd->getViewFrame()->getFitRanges(XMin, XMax, YMin, YMax, Y2Min, Y2Max); - myResult.append(XMin); - myResult.append(XMax); - myResult.append(YMin); - myResult.append(YMax); + wnd->getViewFrame()->getFitRanges( XMin, XMax, YMin, YMax, Y2Min, Y2Max ); + myResult.append( XMin ); + myResult.append( XMax ); + myResult.append( YMin ); + myResult.append( YMax ); } } }; @@ -3891,87 +3856,90 @@ public: double myXMax; double myYMin; double myYMax; - TPlot2dFitRange(const int id, const double XMin, const double XMax, const double YMin, const double YMax) : - myWndId(id), - myXMin(XMin), - myXMax(XMax), - myYMin(YMin), - myYMax(YMax) {} + TPlot2dFitRange( const int id, const double XMin, const double XMax, const double YMin, const double YMax ) : + myWndId( id ), + myXMin( XMin ), + myXMax( XMax ), + myYMin( YMin ), + myYMax( YMax ) {} virtual void Execute() { - Plot2d_ViewWindow* wnd = dynamic_cast(getWnd( myWndId )); - if ( wnd ) - { - wnd->getViewFrame()->fitData(0, myXMin, myXMax, myYMin, myYMax); - } + Plot2d_ViewWindow* wnd = dynamic_cast( getWnd( myWndId ) ); + if ( wnd ) + wnd->getViewFrame()->fitData( 0, myXMin, myXMax, myYMin, myYMax ); } }; -void SalomePyQt::setPlot2dFitRange(const int id, const double XMin, const double XMax, const double YMin, const double YMax) +void SalomePyQt::setPlot2dFitRange( const int id, const double XMin, const double XMax, const double YMin, const double YMax ) { - ProcessVoidEvent( new TPlot2dFitRange(id, XMin, XMax, YMin, YMax) ); + ProcessVoidEvent( new TPlot2dFitRange( id, XMin, XMax, YMin, YMax ) ); } -//class TInitParaview: public SALOME_Event -//{ -//public: -// TInitParaview() {} -// virtual void Execute() { -// LightApp_Application* anApp = getApplication(); -// // Create PVViewer_ViewManager, which will initialize ParaView stuff -// PVViewer_ViewManager* viewMgr = -// dynamic_cast( anApp->getViewManager( PVViewer_Viewer::Type(), true ) ); -// } -//}; -//void SalomePyQt::initializeParaViewGUI() -//{ -// ProcessVoidEvent( new TInitParaview() ); -//} +// End of methods related to the Plot2d viewer functionality +#endif // DISABLE_PLOT2DVIEWER +/*! + \brief Process Qt event loop +*/ void SalomePyQt::processEvents() { QCoreApplication::processEvents(); } -void SalomePyQt::setVisibilityState( const QString& theEntry, VisibilityState theState) +/*! + \brief Set visibility state for given object + \param theEntry study ID of the object + \param theState visibility state +*/ +void SalomePyQt::setVisibilityState( const QString& theEntry, VisibilityState theState ) { class TEvent: public SALOME_Event { QString myEntry; int myState; public: - TEvent( const QString& theEntry, int theState): - myEntry(theEntry), myState(theState) {} + TEvent( const QString& theEntry, int theState ): + myEntry( theEntry ), myState( theState ) {} virtual void Execute() { LightApp_Study* aStudy = getActiveStudy(); if ( !aStudy ) return; - aStudy->setVisibilityState(myEntry, (Qtx::VisibilityState)myState); + aStudy->setVisibilityState( myEntry, (Qtx::VisibilityState)myState ); } }; - ProcessVoidEvent( new TEvent(theEntry, theState ) ); + ProcessVoidEvent( new TEvent( theEntry, theState ) ); } +/*! + \fn VisibilityState SalomePyQt::getVisibilityState( const QString& theEntry ) + \brief Get visibility state for given object + \param theEntry study ID of the object + \return visibility state +*/ + class TGetVisibilityStateEvent: public SALOME_Event { public: typedef int TResult; TResult myResult; QString myEntry; - TGetVisibilityStateEvent(const QString& theEntry) : myResult( 0 ), myEntry(theEntry) {} + TGetVisibilityStateEvent( const QString& theEntry ) : myResult( 0 ), myEntry( theEntry ) {} virtual void Execute() { LightApp_Study* aStudy = getActiveStudy(); if ( aStudy ) - myResult = aStudy->visibilityState(myEntry); + myResult = aStudy->visibilityState( myEntry ); } }; - VisibilityState SalomePyQt::getVisibilityState( const QString& theEntry ) { - return (VisibilityState) ProcessEvent( new TGetVisibilityStateEvent(theEntry) ); + return (VisibilityState) ProcessEvent( new TGetVisibilityStateEvent( theEntry ) ); } - +/*! + \brief Set position of given object in the tree + \param theEntry study ID of the object + \param thePos position +*/ void SalomePyQt::setObjectPosition( const QString& theEntry, int thePos ) { class TEvent: public SALOME_Event @@ -3979,19 +3947,24 @@ void SalomePyQt::setObjectPosition( const QString& theEntry, int thePos ) QString myEntry; int myPos; public: - TEvent( const QString& theEntry, int thePos): - myEntry(theEntry), myPos(thePos) {} + TEvent( const QString& theEntry, int thePos ): + myEntry( theEntry ), myPos( thePos ) {} virtual void Execute() { SALOME_PYQT_ModuleLight* module = dynamic_cast( getActiveModule() ); if ( module ) - module->setObjectPosition(myEntry, myPos ); + module->setObjectPosition( myEntry, myPos ); } }; - ProcessVoidEvent( new TEvent(theEntry, thePos ) ); + ProcessVoidEvent( new TEvent( theEntry, thePos ) ); } - +/*! + \fn int SalomePyQt::getObjectPosition( const QString& theEntry ) + \brief Get position of given object in the tree + \param theEntry study ID of the object + \return position +*/ class TGetObjectPositionEvent: public SALOME_Event { @@ -3999,21 +3972,24 @@ public: typedef int TResult; TResult myResult; QString myEntry; - TGetObjectPositionEvent(const QString& theEntry) : myResult( 0 ), myEntry(theEntry) {} + TGetObjectPositionEvent( const QString& theEntry ) : myResult( 0 ), myEntry( theEntry ) {} virtual void Execute() { SALOME_PYQT_ModuleLight* module = dynamic_cast( getActiveModule() ); if ( module ) - myResult = module->getObjectPosition(myEntry); + myResult = module->getObjectPosition( myEntry ); } }; - int SalomePyQt::getObjectPosition( const QString& theEntry ) { - return ProcessEvent( new TGetObjectPositionEvent(theEntry) ); + return ProcessEvent( new TGetObjectPositionEvent( theEntry ) ); } -void SalomePyQt::startPyLog(const QString& theFileName) +/*! + \brief Start recordind a log of Python commands from embedded console + \param theFileName output lof file name +*/ +void SalomePyQt::startPyLog( const QString& theFileName ) { class TEvent: public SALOME_Event { @@ -4032,6 +4008,9 @@ void SalomePyQt::startPyLog(const QString& theFileName) ProcessVoidEvent( new TEvent( theFileName ) ); } +/*! + \brief Stop recordind a log of Python commands from embedded console +*/ void SalomePyQt::stopPyLog() { class TEvent: public SALOME_Event diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h index 5e04d6627..a9bbd2a82 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h @@ -37,7 +37,9 @@ #include #endif #include +#ifndef DISABLE_PLOT2DVIEWER #include +#endif class LightApp_SelectionMgr; class QMenuBar; @@ -46,7 +48,9 @@ class QWidget; class QAction; class QTreeView; class QtxActionGroup; +#ifndef DISABLE_PLOT2DVIEWER class Plot2d_Curve; +#endif class SALOME_Selection : public QObject { @@ -125,6 +129,7 @@ enum Action { SplitAt = 2 //!< the view area is splitted in such a way, that specified view and all views which follow it, are moved to the new area }; +#ifndef DISABLE_PLOT2DVIEWER //! Type of titles in Plot3d View enum ObjectType { @@ -136,6 +141,7 @@ enum ObjectType YAxis = Plot2d_ViewFrame::YAxis, Y2Axis = Plot2d_ViewFrame::Y2Axis }; +#endif enum VisibilityState { @@ -144,12 +150,14 @@ enum VisibilityState UnpresentableState //!< Unpresentable object }; +#ifndef DISABLE_PLOT2DVIEWER enum Axis { yLeft = QwtPlot::yLeft, yRight = QwtPlot::yRight, xBottom = QwtPlot::xBottom, xTop = QwtPlot::xTop, }; +#endif class SalomePyQt { @@ -286,6 +294,7 @@ public: static bool moveView( const int, const int, const bool ); static QList neighbourViews( const int ); +#ifndef DISABLE_PLOT2DVIEWER static void displayCurve(const int, Plot2d_Curve*); static void eraseCurve(const int, Plot2d_Curve*); static void eraseCurve(Plot2d_Curve*); @@ -295,6 +304,7 @@ public: static QList getPlot2dFitRangeByCurves(const int); static QList getPlot2dFitRangeCurrent(const int); static void setPlot2dFitRange(const int, const double XMin, const double XMax, const double YMin, const double YMax); +#endif // static void initializeParaViewGUI(); static void processEvents(); diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip index 75518ae08..0c32162b1 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip @@ -26,16 +26,20 @@ %Module SalomePyQt %Feature ENABLE_CORBA +%Feature ENABLE_PLOT2D %Import QtGuimod.sip %Import QtXmlmod.sip +%If (ENABLE_PLOT2D) +%Include SalomePyQt_Plot2d.sip +%End + %ExportedHeaderCode #include #include #include #include -#include %End class SALOME_Selection : QObject @@ -106,13 +110,6 @@ enum Action { SplitAt = 2 }; -enum Axis { - yLeft, - yRight, - xBottom, - xTop, -}; - class QtxAction : QWidgetAction { %TypeHeaderCode @@ -209,78 +206,6 @@ private: QtxActionGroup( const QtxActionGroup& ); }; -enum ObjectType -{ - MainTitle, - XTitle, - YTitle, - Y2Title, - XAxis, - YAxis, - Y2Axis -}; - -class Plot2d_Curve -{ -%TypeHeaderCode -#include -%End - -%ConvertToSubClassCode - if ( dynamic_cast( sipCpp ) ) - sipClass = sipClass_Plot2d_Curve; - else - sipClass = NULL; -%End - -public: - Plot2d_Curve(); - virtual ~Plot2d_Curve(); - void setName( const QString& ); - void addPoint( double, double ); - void addPoints(SIP_PYLIST X, SIP_PYLIST Y); -%MethodCode - int nx = PyList_Size(a0); - int ny = PyList_Size(a1); - - if( nx != ny ) { - PyErr_Format(PyExc_TypeError,"The dimension of x and y should be the same. It is %d and %d currently.", nx, ny); - } - - int i; - PyObject *pX, *pY; - - for (i=0; iaddPoint(aX, aY); - } -%End - void insertPoint( int, double, double ); - void deletePoint( int ); - void clearAllPoints(); - void setXAxis( Axis ); -%MethodCode - int ax = int(a0); - sipCpp->setXAxis(QwtPlot::Axis(ax)); -%End - Axis getXAxis() const; -%MethodCode - sipRes = Axis(sipCpp->getXAxis()); -%End - void setYAxis( Axis ); -%MethodCode - int ay = int(a0); - sipCpp->setYAxis(QwtPlot::Axis(ay)); -%End - Axis getYAxis() const; -%MethodCode - sipRes = Axis(sipCpp->getYAxis()); -%End -}; - enum VisibilityState { ShownState, @@ -288,7 +213,6 @@ enum VisibilityState UnpresentableState }; - class SalomePyQt { %TypeHeaderCode @@ -456,6 +380,8 @@ public: static bool moveView( const int, const int, const bool ) /ReleaseGIL/ ; static QList neighbourViews( const int ) /ReleaseGIL/ ; +%If (ENABLE_PLOT2D) +// start Plot2d-related functionality static void displayCurve(const int, Plot2d_Curve*) /ReleaseGIL/ ; static void eraseCurve(const int, Plot2d_Curve*) /ReleaseGIL/ ; static void eraseCurve(Plot2d_Curve*) /ReleaseGIL/ ; @@ -465,9 +391,10 @@ public: static QList getPlot2dFitRangeByCurves(const int) /ReleaseGIL/ ; static QList getPlot2dFitRangeCurrent(const int) /ReleaseGIL/ ; static void setPlot2dFitRange(const int, const double XMin, const double XMax, const double YMin, const double YMax ) /ReleaseGIL/ ; +// end of Plot2d-related functionality +%End static void processEvents(); - static void startPyLog(const QString&) /ReleaseGIL/ ; static void stopPyLog() /ReleaseGIL/ ; diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt_Plot2d.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt_Plot2d.sip new file mode 100644 index 000000000..4612829bd --- /dev/null +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt_Plot2d.sip @@ -0,0 +1,111 @@ +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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, or (at your option) any later version. +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : SalomePyQt.sip +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + +%If (ENABLE_PLOT2D) + +%ExportedHeaderCode +#include +%End + +enum Axis { + yLeft, + yRight, + xBottom, + xTop, +}; + +enum ObjectType +{ + MainTitle, + XTitle, + YTitle, + Y2Title, + XAxis, + YAxis, + Y2Axis +}; + +class Plot2d_Curve +{ +%TypeHeaderCode +#include +%End + +%ConvertToSubClassCode + if ( dynamic_cast( sipCpp ) ) + sipClass = sipClass_Plot2d_Curve; + else + sipClass = NULL; +%End + +public: + Plot2d_Curve(); + virtual ~Plot2d_Curve(); + void setName( const QString& ); + void addPoint( double, double ); + void addPoints(SIP_PYLIST X, SIP_PYLIST Y); +%MethodCode + int nx = PyList_Size(a0); + int ny = PyList_Size(a1); + + if( nx != ny ) { + PyErr_Format(PyExc_TypeError,"The dimension of x and y should be the same. It is %d and %d currently.", nx, ny); + } + + int i; + PyObject *pX, *pY; + + for (i=0; iaddPoint(aX, aY); + } +%End + void insertPoint( int, double, double ); + void deletePoint( int ); + void clearAllPoints(); + void setXAxis( Axis ); +%MethodCode + int ax = int(a0); + sipCpp->setXAxis(QwtPlot::Axis(ax)); +%End + Axis getXAxis() const; +%MethodCode + sipRes = Axis(sipCpp->getXAxis()); +%End + void setYAxis( Axis ); +%MethodCode + int ay = int(a0); + sipCpp->setYAxis(QwtPlot::Axis(ay)); +%End + Axis getYAxis() const; +%MethodCode + sipRes = Axis(sipCpp->getYAxis()); +%End +}; + +%End -- 2.39.2