From: mkr Date: Fri, 19 Jan 2018 09:04:27 +0000 (+0300) Subject: 0054365: Add set rotation point of SALOME viewers functionality into SalomePyQt inter... X-Git-Tag: V8_5_0a1^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fmkr%2F54365;p=modules%2Fgui.git 0054365: Add set rotation point of SALOME viewers functionality into SalomePyQt interface. Implement function in SALOME GUI Python API allowing positioning view rotation's center on a given 3D point. --- diff --git a/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt b/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt index e5c68a0f6..041fa5bee 100755 --- a/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt +++ b/src/SALOME_PYQT/SalomePyQt/CMakeLists.txt @@ -51,6 +51,10 @@ INCLUDE_DIRECTORIES( IF(SALOME_USE_OCCVIEWER) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/OCCViewer) ENDIF(SALOME_USE_OCCVIEWER) +IF(SALOME_USE_VTKVIEWER) + INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/VTKViewer) + INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/SVTK) +ENDIF() IF(SALOME_USE_PVVIEWER) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/PVViewer) ENDIF(SALOME_USE_PVVIEWER) diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx index 04074001c..7b0220096 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx @@ -42,6 +42,9 @@ #include "OCCViewer_ViewWindow.h" #include "OCCViewer_ViewFrame.h" #endif // DISABLE_OCCVIEWER +#ifndef DISABLE_VTKVIEWER +#include "SVTK_ViewWindow.h" +#endif // DISABLE_VTKVIEWER #ifndef DISABLE_PLOT2DVIEWER #include "Plot2d_ViewManager.h" #include "Plot2d_ViewWindow.h" @@ -3004,6 +3007,85 @@ bool SalomePyQt::setViewSize( const int w, const int h, const int id ) return ProcessEvent( new TSetViewSize( w, h, id ) ); } +/*! + \fn bool SalomePyQt::setViewRotationPoint( const double x, const double y, const double z, const int id ); + \brief Set view rotation point + \param x coordinate X view rotation point + \param y coordinate Y view rotation point + \param z coordinate Z view rotation point + \param id window identifier + \return \c true if operation is completed successfully and \c false otherwise +*/ + +class TSetViewRotationPoint: public SALOME_Event +{ +public: + typedef bool TResult; + TResult myResult; + double myX; + double myY; + double myZ; + int myWndId; + TSetViewRotationPoint( const double x, const double y, const double z, const int id ) + : myResult( false ), + myX( x ), + myY( y ), + myZ( z ), + myWndId( id ) {} + virtual void Execute() + { + SUIT_ViewWindow* wnd = 0; + if ( !myWndId ) { + if ( LightApp_Application* anApp = getApplication() ) { + SUIT_ViewManager* vm = anApp->activeViewManager(); + if ( vm ) + wnd = vm->getActiveView(); + } + } + else { + wnd = dynamic_cast( getWnd( myWndId ) ); + } + if ( wnd ) { + SUIT_ViewManager* viewMgr = wnd->getViewManager(); + 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; its rotation point will be changed; + // - if there are several sub-views, rotaion points of each of them will be changed. + OCCViewer_ViewWindow* occView = qobject_cast( wnd ); + if ( occView ) { + for ( int i = OCCViewer_ViewFrame::BOTTOM_RIGHT; i <= OCCViewer_ViewFrame::TOP_RIGHT; i++ ) { + if ( occView && occView->getView( i ) ) { + occView->getView( i )->activateSetRotationSelected( myX, myY, myZ ); + myResult = true; + } + } + } +#endif // DISABLE_OCCVIEWER + } + else if ( type == "VTKViewer") { +#ifndef DISABLE_VTKVIEWER + SVTK_ViewWindow* vtkView = qobject_cast( wnd ); + if ( vtkView ) + { + double aCenter[3] = { myX, myY, myZ }; + vtkView->activateSetRotationSelected( (void*)aCenter ); + myResult = true; + } +#endif // DISABLE_VTKVIEWER + } + } + } + } +}; +bool SalomePyQt::setViewRotationPoint( const double x, const double y, const double z, const int id ) +{ + return ProcessEvent( new TSetViewRotationPoint( x, y, z, id ) ); +} + /*! \fn QString SalomePyQt::getViewTitle( const int id ); \brief Get view caption diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h index 201e1b315..718758998 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.h @@ -308,6 +308,7 @@ public: static bool setViewTitle( const int, const QString& ); static QString getViewTitle( const int ); static bool setViewSize( const int, const int, const int = 0 ); + static bool setViewRotationPoint( const double, const double, const double, const int = 0 ); static QList findViews( const QString& ); static bool activateView( const int ); static bool activateViewManagerAndView( const int ); diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip index e684602e5..bf9a84a18 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip @@ -436,6 +436,7 @@ public: static bool setViewTitle( const int, const QString& ) /ReleaseGIL/ ; static QString getViewTitle( const int ) /ReleaseGIL/ ; static bool setViewSize( const int, const int, const int = 0 ) /ReleaseGIL/ ; + static bool setViewRotationPoint( const double, const double, const double, const int = 0 ) /ReleaseGIL/ ; static QList findViews( const QString& ) /ReleaseGIL/ ; static bool activateView( const int ) /ReleaseGIL/ ; static bool activateViewManagerAndView( const int ) /ReleaseGIL/ ;