]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
0054365: Add set rotation point of SALOME viewers functionality into SalomePyQt inter... mkr/54365 V8_5_0a1
authormkr <mkr@opencascade.com>
Fri, 19 Jan 2018 09:04:27 +0000 (12:04 +0300)
committermkr <mkr@opencascade.com>
Fri, 19 Jan 2018 15:28:30 +0000 (18:28 +0300)
src/SALOME_PYQT/SalomePyQt/CMakeLists.txt
src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx
src/SALOME_PYQT/SalomePyQt/SalomePyQt.h
src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip

index e5c68a0f60c63a1fd263824ec300fd056e991f9a..041fa5beefbb52e0037b4cf8ecff9b1b529eb466 100755 (executable)
@@ -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)
index 04074001c49a9dfe05d0d07a5d7c38b8f74576c1..7b0220096e5b1c0d8b92b33abfc9c8ca77e3c187 100644 (file)
@@ -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<SUIT_ViewWindow*>( 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<OCCViewer_ViewWindow*>( 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<SVTK_ViewWindow*>( 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  
index 201e1b315a8f9de7a15bf87c79947ceca27dee2e..71875899811deb8ec0dbdc721f0357be75a3580f 100644 (file)
@@ -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<int>        findViews( const QString& );
   static bool              activateView( const int );
   static bool              activateViewManagerAndView( const int );
index e684602e5e2aeba5399b6b8cbc7ea6287b6bb033..bf9a84a187b79d873df1e44937da057a9ab6c2a7 100644 (file)
@@ -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<int>        findViews( const QString& ) /ReleaseGIL/ ;
   static bool              activateView( const int ) /ReleaseGIL/ ;
   static bool              activateViewManagerAndView( const int ) /ReleaseGIL/ ;