Salome HOME
Minor bug fix for ALAMOS
[modules/gui.git] / src / SALOME_PYQT / SalomePyQt / SalomePyQt.cxx
old mode 100755 (executable)
new mode 100644 (file)
index e8ace54..e6edb9d
@@ -41,6 +41,8 @@
 #include "OCCViewer_ViewWindow.h"
 #include "Plot2d_ViewManager.h"
 #include "Plot2d_ViewWindow.h"
+#include "PVViewer_ViewManager.h"
+#include "PVViewer_ViewModel.h"
 #include "QtxActionMenuMgr.h"
 #include "QtxWorkstack.h"
 #include "QtxTreeView.h"
 #include "SUIT_ResourceMgr.h"
 #include "SUIT_Session.h"
 #include "SUIT_Tools.h"
+#include "PyConsole_Console.h"
 
 #include <QAction>
 #include <QApplication>
 #include <QPaintEvent>
+#include <QCoreApplication>
 
 /*!
   \brief Get the currently active application.
@@ -1549,37 +1553,38 @@ int SalomePyQt::defaultMenuGroup()
 class CrTool
 {
 public:
-  CrTool( const QString& tBar ) 
-    : myCase( 0 ), myTbName( tBar ) {}
+  CrTool( const QString& tBar, const QString& nBar ) 
+    : myCase( 0 ), myTbTitle( tBar ), myTbName( nBar)  {}
   CrTool( const int id, const int tBar, const int idx ) 
     : myCase( 1 ), myId( id ), myTbId( tBar ), myIndex( idx ) {}
   CrTool( const int id, const QString& tBar, const int idx )
-    : myCase( 2 ), myId( id ), myTbName( tBar ), myIndex( idx ) {}
+    : myCase( 2 ), myId( id ), myTbTitle( tBar ), myIndex( idx ) {}
   CrTool( QAction* action, const int tbId, const int id, const int idx )
     : myCase( 3 ), myAction( action ), myTbId( tbId ), myId( id ), myIndex( idx ) {}
   CrTool( QAction* action, const QString& tBar, const int id, const int idx )
-    : myCase( 4 ), myAction( action ), myTbName( tBar ), myId( id ), myIndex( idx ) {}
+    : myCase( 4 ), myAction( action ), myTbTitle( tBar ), myId( id ), myIndex( idx ) {}
 
   int execute( LightApp_Module* module ) const
   {
     if ( module ) {
       switch ( myCase ) {
       case 0:
-        return module->createTool( myTbName );
+        return module->createTool( myTbTitle, myTbName );
       case 1:
         return module->createTool( myId, myTbId, myIndex );
       case 2:
-        return module->createTool( myId, myTbName, myIndex );
+        return module->createTool( myId, myTbTitle, myIndex );
       case 3:
         return module->createTool( myAction, myTbId, myId, myIndex );
       case 4:
-        return module->createTool( myAction, myTbName, myId, myIndex );
+        return module->createTool( myAction, myTbTitle, myId, myIndex );
       }
     }
     return -1;
   }
 private:
    int        myCase;
+   QString    myTbTitle;
    QString    myTbName;
    int        myTbId;
    QAction*   myAction;
@@ -1605,12 +1610,13 @@ public:
 
 /*!
   \brief Create toolbar with specified name.
-  \param tBar toolbar name
+  \param tBar toolbar title (language-dependent)
+  \param nBar toolbar name (language-independent) [optional]
   \return toolbar ID or -1 if toolbar creation is failed
 */
-int SalomePyQt::createTool( const QString& tBar )
+int SalomePyQt::createTool( const QString& tBar, const QString& nBar )
 {
-  return ProcessEvent( new TCreateToolEvent( CrTool( tBar ) ) );
+  return ProcessEvent( new TCreateToolEvent( CrTool( tBar, nBar ) ) );
 }
 
 /*! 
@@ -2651,7 +2657,9 @@ public:
 };
 int SalomePyQt::createView( const QString& type, bool visible, const int width, const int height )
 {
-  return ProcessEvent( new TCreateView( type, visible, width, height ) );
+  int ret = ProcessEvent( new TCreateView( type, visible, width, height ) );
+  QCoreApplication::processEvents();
+  return ret;
 }
 
 /*!
@@ -3823,6 +3831,26 @@ void SalomePyQt::setPlot2dFitRange(const int id, const double XMin, const double
        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<PVViewer_ViewManager*>( anApp->getViewManager( PVViewer_Viewer::Type(), true ) );
+//  }
+//};
+//void SalomePyQt::initializeParaViewGUI()
+//{
+//  ProcessVoidEvent( new TInitParaview() );
+//}
+
+void SalomePyQt::processEvents()
+{
+  QCoreApplication::processEvents();
+}
 
 void SalomePyQt::setVisibilityState( const QString& theEntry, VisibilityState theState)
 {
@@ -3905,3 +3933,39 @@ int SalomePyQt::getObjectPosition( const QString& theEntry )
 {
   return ProcessEvent( new TGetObjectPositionEvent(theEntry) );
 }
+
+void SalomePyQt::startPyLog(const QString& theFileName)
+{
+  class TEvent: public SALOME_Event
+  {
+    QString myFileName;
+  public:
+    TEvent( const QString& theFileName ):
+      myFileName( theFileName ) {}
+    virtual void Execute() 
+    {
+      if ( getApplication() ) {
+       PyConsole_Console* pyConsole = getApplication()->pythonConsole( false );
+       if ( pyConsole ) pyConsole->startLog( myFileName );
+      }
+    }
+  };
+  ProcessVoidEvent( new TEvent( theFileName ) );
+}
+
+void SalomePyQt::stopPyLog()
+{
+  class TEvent: public SALOME_Event
+  {
+  public:
+    TEvent() {}
+    virtual void Execute() 
+    {
+      if ( getApplication() ) {
+       PyConsole_Console* pyConsole = getApplication()->pythonConsole( false );
+       if ( pyConsole ) pyConsole->stopLog();
+      }
+    }
+  };
+  ProcessVoidEvent( new TEvent() );
+}