]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Access from python to scene.
authorageay <ageay>
Fri, 22 Jul 2011 09:18:02 +0000 (09:18 +0000)
committerageay <ageay>
Fri, 22 Jul 2011 09:18:02 +0000 (09:18 +0000)
src/SALOME_PYQT/SalomePyQt/Makefile.am
src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx
src/SALOME_PYQT/SalomePyQt/SalomePyQt.h
src/SALOME_PYQT/SalomePyQt/SalomePyQt.sip

index 223858437a1a970e2b689c06023d2d4c7fa143f8..9b5a932e4f8b86e4a223f3e8486ba4fd1d71fcf0 100644 (file)
@@ -56,6 +56,7 @@ COMMON_CPP_FLAGS = $(QT_INCLUDES) $(QWT_INCLUDES) $(SIP_INCLUDES) $(PYTHON_INCLU
        -I$(srcdir)/../../Qtx -I$(srcdir)/../../Event                                    \
        -I$(srcdir)/../../LogWindow                                                      \
        -I$(srcdir)/../../VTKViewer                                                      \
+       -I$(srcdir)/../../QxScene                                                        \
        -I$(srcdir)/../../OCCViewer -I$(srcdir)/../../Plot2d                             \
        -I$(srcdir)/../SALOME_PYQT_GUILight -I$(srcdir)/../../PyInterp                   \
        -I$(srcdir)/../../LightApp -I$(srcdir)/../../ObjBrowser                          \
index bfda59f2dd1e6386088370fd2949cc52f9215d86..17e4d940cbedc4b82de22473c90c11d5a65d7654 100644 (file)
@@ -60,6 +60,8 @@
 #include <OCCViewer_ViewWindow.h>
 #include <Plot2d_ViewManager.h>
 #include <Plot2d_ViewWindow.h>
+#include <QxScene_ViewManager.h>
+#include <QxScene_ViewWindow.h>
 
 /*!
   \brief Get the currently active application.
@@ -2365,6 +2367,81 @@ int SalomePyQt::createView( const QString& type )
   return ProcessEvent( new TCreateView( type ) );
 }
 
+/*!
+  \fn QGraphicsScene* SalomePyQt::initQxScene()
+  \brief: create a scene, a view in central widget
+  \return a scene or NULL
+*/
+
+class TinitQxScene: public SALOME_Event
+{
+public:
+  typedef QGraphicsScene* TResult;
+  TResult myResult;
+
+  TinitQxScene(): myResult(NULL) {
+  }
+
+  virtual void Execute() {
+    LightApp_Application* app  = getApplication();
+    if ( app ) {
+      QxScene_ViewManager* aVM = dynamic_cast<QxScene_ViewManager*>( app->getViewManager( "QxSceneViewer", true ) );
+      if ( aVM ) {
+        QxScene_ViewWindow* view = dynamic_cast<QxScene_ViewWindow*>( aVM->getActiveView() );
+
+        QGraphicsScene* scene = new QGraphicsScene(view);
+        QGraphicsView * gView = new QGraphicsView();
+
+        view->setScene(scene);
+        view->setSceneView(gView);
+        view->setCentralWidget(gView);
+
+        gView->setScene(scene);
+        gView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
+        gView->show();
+
+        myResult = scene;
+      }
+    }
+  }
+};
+
+QGraphicsScene* SalomePyQt::initQxScene() {
+  return ProcessEvent( new TinitQxScene() );
+}
+
+/*!
+  \fn QMainWindow* SalomePyQt::getQxMainWindow( const bool create );
+  \brief: get the active QMainWindow or created one
+  \return a QMainWindow or NULL
+*/
+
+class TgetQxMainWindow: public SALOME_Event
+{
+public:
+  typedef QMainWindow* TResult;
+  TResult myResult;
+  const bool _create;
+
+  TgetQxMainWindow(const bool create): _create(create), myResult(NULL) {
+  }
+
+  virtual void Execute() {
+    LightApp_Application* app  = getApplication();
+    if ( app ) {
+      QxScene_ViewManager* aVM = dynamic_cast<QxScene_ViewManager*>( app->getViewManager( "QxSceneViewer", _create ) );
+      if ( aVM ) {
+        QxScene_ViewWindow* view = dynamic_cast<QxScene_ViewWindow*>( aVM->getActiveView() );
+        myResult = view;
+    }
+  }
+  }
+};
+
+QMainWindow* SalomePyQt::getQxMainWindow( const bool create ) {
+  return ProcessEvent( new TgetQxMainWindow(create) );
+}
+
 /*!
   \fn bool SalomePyQt::closeView( const int id )
   \brief Close view
index 0aaa9f395cb0772080c90bfa7e8cb4475cbf8dd0..4791a19d80fa92b85e5c467ba1d8d3e4cf329d8d 100644 (file)
@@ -40,6 +40,8 @@ class QMenu;
 class QWidget;
 class QAction;
 class QtxActionGroup;
+class QGraphicsScene;
+class QMainWindow;
 
 class SALOME_Selection : public QObject
 {
@@ -178,7 +180,7 @@ public:
   static QAction*          createAction( const int, const QString&,
                                          const QString& = QString(), const QString& = QString(), 
                                          const QString& = QString(), const int = 0, const bool = false );
-  
+
   static QtxActionGroup*   createActionGroup( const int, const bool = true );
 
   static QAction*          action( const int );
@@ -221,7 +223,7 @@ public:
 
   static void              message( const QString&, bool = true );
   static void              clearMessages();
-  
+
   static QList<int>        getViews();
   static int               getActiveView();
   static QString           getViewType( const int );
@@ -233,7 +235,9 @@ public:
   static bool              closeView( const int );
   static int               cloneView( const int );
   static bool              isViewVisible( const int id );
-  
+  static QGraphicsScene*   initQxScene();
+  static QMainWindow*      getQxMainWindow( const bool create );
+
   static bool              groupAllViews();
   static bool              splitView( const int, const Orientation, const Action );
   static bool              moveView( const int, const int, const bool );
index 60bbb4f420ac7de3c64d4312399eea3548fea43f..4f8ad525f94c68b48bf23f72368d924fdeaef0df 100644 (file)
@@ -320,7 +320,8 @@ public:
   static bool              closeView( const int ) /ReleaseGIL/ ;
   static int               cloneView( const int ) /ReleaseGIL/ ;
   static bool              isViewVisible( const int id ) /ReleaseGIL/ ;
-  
+  static QGraphicsScene*   initQxScene() /ReleaseGIL/ ;
+  static QMainWindow*      getQxMainWindow( const bool ) /ReleaseGIL/ ;
   static bool              groupAllViews() /ReleaseGIL/ ;
   static bool              splitView( const int, Orientation, Action ) /ReleaseGIL/ ;
   static bool              moveView( const int, const int, const bool ) /ReleaseGIL/ ;