Salome HOME
Merge branch 'master' into V7_5_BR
authorvsr <vsr@opencascade.com>
Wed, 12 Nov 2014 16:42:03 +0000 (19:42 +0300)
committervsr <vsr@opencascade.com>
Wed, 12 Nov 2014 16:42:03 +0000 (19:42 +0300)
26 files changed:
CMakeLists.txt
doc/salome/gui/input/introduction_to_gui.doc
doc/salome/gui/input/salome_desktop.doc
doc/salome/gui/input/study_management_chapter.doc
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Application.h
src/LightApp/LightApp_PyInterp.h
src/PyConsole/PyConsole_Console.cxx
src/PyConsole/PyConsole_Console.h
src/PyConsole/PyConsole_Editor.cxx
src/PyConsole/PyConsole_Editor.h
src/PyConsole/PyConsole_EnhEditor.cxx
src/PyConsole/PyConsole_EnhEditor.h
src/PyConsole/PyConsole_EnhInterp.cxx
src/PyConsole/PyConsole_EnhInterp.h
src/PyConsole/PyConsole_Interp.cxx
src/PyConsole/PyConsole_Interp.h
src/PyConsole/PyConsole_Request.cxx
src/PyConsole/PyConsole_Request.h
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Application.h
src/SalomeApp/SalomeApp_DoubleSpinBox.cxx
src/SalomeApp/SalomeApp_IntSpinBox.cxx
src/SalomeApp/SalomeApp_NoteBook.cxx
src/SalomeApp/SalomeApp_PyInterp.h
src/SalomeApp/SalomeApp_Study.cxx

index 274140c448887ad528b8a98283fb324cf6e13c5b..2ce226a174b9d7d1959f9ebba93ec62d8bb68850 100755 (executable)
@@ -30,11 +30,11 @@ CMAKE_POLICY(SET CMP0003 NEW)
 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
 
 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
-SET(${PROJECT_NAME_UC}_MINOR_VERSION 4)
-SET(${PROJECT_NAME_UC}_PATCH_VERSION 1)
+SET(${PROJECT_NAME_UC}_MINOR_VERSION 5)
+SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
 SET(${PROJECT_NAME_UC}_VERSION
   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
-SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
+SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
 
 # Find KERNEL
 # ===========
index 1814130db825bc5879c3f18490dfe2ba278825e8..75c02ae4140222345b989be71c3bcd2a29da3581 100644 (file)
@@ -22,7 +22,7 @@ basic GUI functionalities, common for all modules.
 
 <ul>
 <li>\b File menu corresponds to \subpage study_management_page "Study management" functionalities
-(creation, saving, loading, editing studies, connecting, disconnecting, etc.).</li>
+(creation, saving, loading, connecting, disconnecting, editing studies, etc.)</li>
 <li>\b Edit menu gives access to <b> Copy/Paste</b> allowing to paste the
 objects from one study into the other. The availability of this
 functionality depends on the module and the nature of an operation or
index d4a64281f81ad4fcbe8164ea07e3bbc92e77d83d..2eb5ffd460e61f61ad83f789c4c68f97c99c3889 100644 (file)
@@ -3,23 +3,23 @@
 \page salome_desktop_page SALOME desktop
 
 SALOME applies <b>Single Document Interface</b> (SDI) approach. Only one 
-\ref study_management_page "study (document)" can be opened at the moment.
+\ref study_management_page "study (document)" can be opened at any given moment.
 
-The front-end of the application is represented as a single Desktop top-level window
-that embeds all GUI operations. Desktop window provides access to standard GUI elements
-like viewers, main menu, toolbars, dock windows, dialog boxes, etc. 
+The front-end of the application is a single Desktop top-level window
+that embeds all GUI operations. The desktop window provides access to standard GUI elements,
+such as viewers, main menu, toolbars, dockable windows, dialog boxes, etc. 
 
 The main elements of the SALOME Desktop are represented on the picture below:
 
 \image html desktop.png
 
 The main parts of the SALOME Desktop are:
-- <b>Main menu</b> - This is a set of context-sensitive menus, which will
-be updated according to the functionality of the currently active component. In
+- <b>Main menu</b> - This is a set of context-sensitive menus
+updated according to the functionality of the currently active component. In
 general, these menus contain all functional options of SALOME platform.
 - <b>Standard toolbar</b> - contains standard actions
 that allow creating new or opening existing study, saving study, deleting
-objects etc.
+objects, etc.
 - <b>Components toolbar</b> - allows activating
 components in SALOME platform.
 - <b>Module toolbars</b> - contain actions specific to the
index 945971e3e13d80ccb699a9d8ff7a8dab4a10f7c2..68b3774ab5c3f05ba06b71e1ad5b4d9a3c150d5d 100644 (file)
@@ -2,7 +2,7 @@
 
 \page study_management_page Study management
 
-Study is a document within application, where you can carry out all
+Study is a document within the application, where you can carry out all
 operations provided by the SALOME functionality. 
 This is a certain abstraction layer between actual
 document data (probably, remote data available through CORBA) and data
@@ -14,21 +14,21 @@ All operations with study are available from the \b File menu.
 \note SALOME is a single-study application. It means that only one study
 can be opened at the moment.
 
-Immediately after application start-up there is (normally) no active study.
+Immediately after the application is launched there is (normally) no active study.
 However, you have access to the embedded Python console, that can be used to initialize
-the study by means of Python API (see documentation on SALOME KERNEL module for more details).
+a study by means of Python API (see documentation on SALOME KERNEL module for more details).
 
 The following operations are available from the \b File menu:
 
 \image html menu_file.png
 
-As soon as study is created, loaded from the file or from the data server,
-some additional operations become available from the \b File menu:
+As soon as a study is created or loaded from a file or a data server,
+additional operations become available from the \b File menu:
 
 \image html studymanagement.png
 
 \b New - creates a new study. The study will be created
-with default name \b Study1. If there is already opened study,
+with default name \b Study1. If there is an already opened study,
 you will be asked to close it before creating new one.
 
 \b Open - allows to open an existing study by browsing for it in a
@@ -70,7 +70,7 @@ by the following dialog box with several options:
 
 \b Disconnect - unloads the current study from the desktop. The study stays opened
 in the data server; it can be then reloaded in the same working session
-(\b Connect operation), but if you quit SALOME application, all changes in the
+(using \b Connect operation), but if you quit SALOME application, all changes in the
 unloaded study can be lost.
 
 \note If the study has not been previously saved, you will be prompted
index 2229aa3eaaf8d4629169146f3f7ddbf4f7f1c4b2..56b3f88527f7a8b1aca507791d8b4e9eef0e14c3 100644 (file)
@@ -221,7 +221,6 @@ static const char* imageEmptyIcon[] = {
 
 int LightApp_Application::lastStudyId = 0;
 
-
 // Markers used to parse array with dockable windows and toolbars state.
 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
 // in the Qt source code.
@@ -1616,7 +1615,7 @@ void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
 
 #ifndef DISABLE_PYCONSOLE
   if( pythonConsole() )
-    pythonConsole()->getInterp()->initStudy();
+    getPyInterp()->initStudy();
 #endif
 }
 
@@ -1647,7 +1646,7 @@ void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
 
 #ifndef DISABLE_PYCONSOLE
   if( pythonConsole() )
-    pythonConsole()->getInterp()->initStudy();
+    getPyInterp()->initStudy();
 #endif
 
   emit studyOpened();
@@ -1916,7 +1915,7 @@ QWidget* LightApp_Application::createWindow( const int flag )
 #ifndef DISABLE_PYCONSOLE
   else  if ( flag == WT_PyConsole )
   {
-    PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(),new LightApp_PyInterp());
+    PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), getPyInterp() );
     pyCons->setObjectName( "pythonConsole" );
     pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
     pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
@@ -4456,3 +4455,19 @@ bool LightApp_Application::checkExistingDoc()
   return result;
 }
 
+#ifndef DISABLE_PYCONSOLE
+
+PyConsole_Interp* LightApp_Application::getPyInterp()
+{
+  static PyConsole_Interp* myInterp = 0;
+  if ( !myInterp )
+    myInterp = createPyInterp();
+  return myInterp;
+}
+
+PyConsole_Interp* LightApp_Application::createPyInterp()
+{
+  return new LightApp_PyInterp();
+}
+
+#endif // DISABLE_PYCONSOLE
index 3ea6cb1ddfa5535887b921069f39c8459ab65feb..54be0df781f7e9e4622c2fd155a5b4a1300b2fa7 100644 (file)
@@ -42,6 +42,7 @@
 class LogWindow;
 #ifndef DISABLE_PYCONSOLE
 class PyConsole_Console;
+class PyConsole_Interp;
 #endif
 class LightApp_WidgetContainer;
 class LightApp_Preferences;
@@ -182,6 +183,10 @@ public:
 
   virtual bool                        checkExistingDoc();
 
+#ifndef DISABLE_PYCONSOLE
+  PyConsole_Interp*                   getPyInterp();
+#endif
+
 signals:
   void                                studyOpened();
   void                                studySaved();
@@ -231,6 +236,10 @@ protected:
   virtual QMap<int, QString>          activateModuleActions() const;
   virtual void                        moduleActionSelected( const int );
 
+#ifndef DISABLE_PYCONSOLE
+  virtual PyConsole_Interp*           createPyInterp();
+#endif
+
 protected slots:
   virtual void                        onDesktopActivated();
   virtual void                        onViewManagerRemoved( SUIT_ViewManager* );
index de8c2663666c9b9559c980d5b5558e42850ba591..7f35fbb25d19fdf8201407e45dd643d9d838d455 100644 (file)
 
 class LightApp_PyInterp : public PyConsole_EnhInterp
 {
+  friend class LightApp_Application;
+
 public:
-  LightApp_PyInterp();
   virtual ~LightApp_PyInterp();
   
 protected:
+  LightApp_PyInterp();
   virtual void initPython();
 };
 
index a3991bf88a8885103e52a684776b8716e737f344..5ec6eb57e07d45cf0890d7f06580052c7516b1ae 100644 (file)
 PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* interp )
 : QWidget( parent )
 {
-  // create python interpreter
-  myInterp = interp;
-  if ( !myInterp )
-    myInterp = new PyConsole_Interp();
+  PyConsole_Interp* anInterp = interp ? interp : new PyConsole_Interp();
   
   // initialize Python interpretator
-  myInterp->initialize();
+  anInterp->initialize();
   
   // create editor console
   QVBoxLayout* lay = new QVBoxLayout( this );
   lay->setMargin( 0 );
-  myEditor = new PyConsole_Editor( myInterp, this );
+  myEditor = new PyConsole_Editor( anInterp, this );
   char* synchronous = getenv("PYTHON_CONSOLE_SYNC");
   if (synchronous && atoi(synchronous))
   {
@@ -78,8 +75,8 @@ PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* interp
 /**
  * Protected constructor.
  */
-PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* i,  PyConsole_Editor* e)
-  : QWidget (parent), myEditor(e), myInterp(i)
+PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* /*i*/,  PyConsole_Editor* e )
+  : QWidget (parent), myEditor(e)
 {}
 
 /*!
@@ -91,6 +88,11 @@ PyConsole_Console::~PyConsole_Console()
 {
 }
 
+PyConsole_Interp* PyConsole_Console::getInterp() const
+{
+  return myEditor ? myEditor->getInterp() : 0;
+} 
+
 /*!
   \brief Execute python command in the interpreter.
   \param command string with command and arguments
@@ -373,21 +375,18 @@ void PyConsole_Console::stopLog()
  * @param parent
  * @param interp
  */
-PyConsole_EnhConsole::PyConsole_EnhConsole( QWidget* parent, PyConsole_EnhInterp* interp)
-  : PyConsole_Console(parent, interp, 0)
+PyConsole_EnhConsole::PyConsole_EnhConsole( QWidget* parent, PyConsole_Interp* interp )
+  : PyConsole_Console( parent, interp, 0 )
 {
-  // create python interpreter
-  myInterp = interp;
-  if ( !myInterp )
-    myInterp = new PyConsole_EnhInterp();
+  PyConsole_Interp* anInterp = interp ? interp : new PyConsole_EnhInterp();
 
   // initialize Python interpretator
-  myInterp->initialize();
+  anInterp->initialize();
 
   // create editor console
   QVBoxLayout* lay = new QVBoxLayout( this );
   lay->setMargin( 0 );
-  myEditor = new PyConsole_EnhEditor( static_cast<PyConsole_EnhInterp*>(myInterp), this );
+  myEditor = new PyConsole_EnhEditor( anInterp, this );
   char* synchronous = getenv("PYTHON_CONSOLE_SYNC");
   if (synchronous && atoi(synchronous))
   {
index 54442c2cd9c162cf2ed847410406789064866075..b32b078e40f0eeb789ceda5da7cc3e975e20093b 100644 (file)
@@ -34,7 +34,6 @@
 
 class PyConsole_Interp;
 class PyConsole_Editor;
-class PyConsole_EnhInterp;
 
 class PYCONSOLE_EXPORT PyConsole_Console : public QWidget, public SUIT_PopupClient
 {
@@ -59,7 +58,7 @@ public:
   virtual ~PyConsole_Console();
 
   //! \brief Get python interperter
-  PyConsole_Interp*   getInterp() { return myInterp; } 
+  PyConsole_Interp*   getInterp() const;
   QFont               font() const;
   virtual void        setFont( const QFont& );
 
@@ -93,8 +92,6 @@ protected:
 
   PyConsole_Console( QWidget* parent, PyConsole_Interp*,  PyConsole_Editor*);
 
-
-  PyConsole_Interp*   myInterp;    //!< python interpreter
   PyConsole_Editor*   myEditor;    //!< python console editor widget
   QMap<int, QAction*> myActions;   //!< menu actions list
 };
@@ -109,7 +106,7 @@ class PYCONSOLE_EXPORT PyConsole_EnhConsole: public PyConsole_Console
   Q_OBJECT
 
 public:
-  PyConsole_EnhConsole( QWidget* parent, PyConsole_EnhInterp* interp = 0);
+  PyConsole_EnhConsole( QWidget* parent, PyConsole_Interp* interp = 0 );
   virtual ~PyConsole_EnhConsole() {}
 };
 
index 42ea63e4f6c5f6b07fe9c986f011fc07d6347c89..aeb61f965e0cc5dd56d67116a539bd09eb3d5050 100644 (file)
@@ -191,16 +191,20 @@ PyConsole_Editor::PyConsole_Editor( PyConsole_Interp* theInterp,
 
 /*!
   \brief Destructor.
-
-  Does nothing for the moment.
 */
 PyConsole_Editor::~PyConsole_Editor()
 {
-  myInterp->destroy();
-  delete myInterp;
   myInterp = 0;
 }
 
+/*!
+  \brief Get Python interpreter
+*/
+PyConsole_Interp* PyConsole_Editor::getInterp() const
+{
+  return myInterp;
+}
+
 /*!
   \brief Get synchronous mode flag value.
   
index c939ef1b7da3e9fd78f947738427b11222426a42..5094f8687861c8451e83ff5594300961f884a6e3 100644 (file)
@@ -42,6 +42,8 @@ class PYCONSOLE_EXPORT PyConsole_Editor : public QTextEdit
 public:
   PyConsole_Editor( PyConsole_Interp* theInterp, QWidget *theParent = 0 );
   ~PyConsole_Editor();
+
+  PyConsole_Interp* getInterp() const;
   
   virtual void   addText( const QString& str, const bool newBlock = false, const bool isError = false );
   bool           isCommand( const QString& str ) const;
index 20a5ef1c5e7003f0d168e6dd5c0ad0d47daf69d6..aa73ac04b33bb752a9bad6dff386c93c6b729631 100644 (file)
@@ -43,7 +43,7 @@ const std::vector<QString> PyConsole_EnhEditor::SEPARATORS = \
  * @param interp the interpreter linked to the editor
  * @param parent parent widget
  */
-PyConsole_EnhEditor::PyConsole_EnhEditor(PyConsole_EnhInterp * interp, QWidget * parent) :
+PyConsole_EnhEditor::PyConsole_EnhEditor(PyConsole_Interp* interp, QWidget* parent) :
      PyConsole_Editor(interp, parent),
      _tab_mode(false),
      _cursor_pos(-1),
@@ -117,7 +117,8 @@ void PyConsole_EnhEditor::clearCompletion()
       setTextCursor(tc);
       textCursor().deletePreviousChar();
       // TODO: before wait for any TAB event to be completed
-      static_cast<PyConsole_EnhInterp *>(myInterp)->clearCompletion();
+      if ( myInterp ) 
+       myInterp->clearCompletion();
     }
   _tab_mode = false;
 }
@@ -222,8 +223,8 @@ PyInterp_Request* PyConsole_EnhEditor::createTabRequest( const QString& input )
       _compl_before_point = QString("");
     }
 
-  return new CompletionCommand( static_cast<PyConsole_EnhInterp *>(myInterp), _compl_before_point,
-                               _compl_after_point, this, isSync() );
+  return new CompletionCommand( myInterp, _compl_before_point,
+                               _compl_after_point, this, isSync() );
 }
 
 /**
@@ -231,7 +232,7 @@ PyInterp_Request* PyConsole_EnhEditor::createTabRequest( const QString& input )
  * @param matches list of possible completions
  * @param result return value
  */
-void PyConsole_EnhEditor::formatCompletion(const std::vector<QString> & matches, QString & result) const
+void PyConsole_EnhEditor::formatCompletion(const QStringList& matches, QString& result) const
 {
   int sz = matches.size();
 
@@ -255,90 +256,97 @@ void PyConsole_EnhEditor::formatCompletion(const std::vector<QString> & matches,
  */
 void PyConsole_EnhEditor::customEvent( QEvent* event )
 {
-  std::vector<QString> matches;
+  QStringList matches;
   QString first_match, comple_text, doc, base;
   QTextCursor cursor(textCursor());
   QTextBlockFormat bf;
   QTextCharFormat cf;
-  PyConsole_EnhInterp * interp = static_cast<PyConsole_EnhInterp *>(myInterp);
   int cursorPos;
 
   switch( event->type() )
   {
     case PyInterp_Event::ES_TAB_COMPLETE_OK:
+    {
       // Extract corresponding matches from the interpreter
-      matches = interp->getLastMatches();
+      matches = getInterp()->getLastMatches();
+      doc = getInterp()->getDocStr();
 
       if (matches.size() == 0)
-        {
-          // Completion successful but nothing returned.
-          _tab_mode = false;
-          _cursor_pos = -1;
-          return;
-        }
-
+      {
+       // Completion successful but nothing returned.
+       _tab_mode = false;
+       _cursor_pos = -1;
+       return;
+      }
+      
       // Only one match - complete directly and update doc string window
-      doc = interp->getDocStr();
       if (matches.size() == 1)
-        {
-          first_match = matches[0].mid(_compl_after_point.size());
-          cursor.insertText(first_match);
-          _tab_mode = false;
-          if (doc == QString(""))
-            emit updateDoc(formatDocHTML("(no documentation available)\n"));
-          else
-            emit updateDoc(formatDocHTML(doc));
-        }
+      {
+       first_match = matches[0].mid(_compl_after_point.size());
+       cursor.insertText(first_match);
+       _tab_mode = false;
+       if (doc.isEmpty())
+         emit updateDoc(formatDocHTML("(no documentation available)\n"));
+       else
+         emit updateDoc(formatDocHTML(doc));
+      }
       else
-        {
-          // Detect if there is a common base to all available completion
-          // In this case append this base to the text already
-          extractCommon(matches, base);
-          first_match = base.mid(_compl_after_point.size());
-          cursor.insertText(first_match);
-
-          // If this happens to match exaclty the first completion
-          // also provide doc
-          if (base == matches[0])
-            {
-              doc = formatDocHTML(doc);
-              emit updateDoc(doc);
-            }
-
-          // Print all matching completion in a "undo-able" block
-          cursorPos = cursor.position();
-          cursor.insertBlock();
-          cursor.beginEditBlock();
-
-          // Insert all matches
-          QTextCharFormat cf;
-          cf.setForeground(QBrush(Qt::darkGreen));
-          cursor.setCharFormat(cf);
-          formatCompletion(matches, comple_text);
-          cursor.insertText(comple_text);
-          cursor.endEditBlock();
-
-          // Position cursor where it was before inserting the completion list:
-          cursor.setPosition(cursorPos);
-          setTextCursor(cursor);
-        }
+      {
+       // Detect if there is a common base to all available completion
+       // In this case append this base to the text already
+       extractCommon(matches, base);
+       first_match = base.mid(_compl_after_point.size());
+       cursor.insertText(first_match);
+       
+       // If this happens to match exaclty the first completion
+       // also provide doc
+       if (base == matches[0])
+       {
+         doc = formatDocHTML(doc);
+         emit updateDoc(doc);
+       }
+       
+       // Print all matching completion in a "undo-able" block
+       cursorPos = cursor.position();
+       cursor.insertBlock();
+       cursor.beginEditBlock();
+       
+       // Insert all matches
+       QTextCharFormat cf;
+       cf.setForeground(QBrush(Qt::darkGreen));
+       cursor.setCharFormat(cf);
+       formatCompletion(matches, comple_text);
+       cursor.insertText(comple_text);
+       cursor.endEditBlock();
+       
+       // Position cursor where it was before inserting the completion list:
+       cursor.setPosition(cursorPos);
+       setTextCursor(cursor);
+      }
       break;
+    }
     case PyInterp_Event::ES_TAB_COMPLETE_ERR:
+    {
       // Tab completion was unsuccessful, switch off mode:
       _tab_mode = false;
       _cursor_pos = -1;
       break;
+    }
     case PyInterp_Event::ES_OK:
     case PyInterp_Event::ES_ERROR:
     case PyInterp_Event::ES_INCOMPLETE:
+    {
       // Before everything else, call super()
       PyConsole_Editor::customEvent(event);
       // If we are in multi_paste_mode, process the next item:
       multiLineProcessNextLine();
       break;
+    }
     default:
+    {
       PyConsole_Editor::customEvent( event );
       break;
+    }
   }
 }
 
@@ -347,7 +355,7 @@ void PyConsole_EnhEditor::customEvent( QEvent* event )
  * @param matches
  * @param result
  */
-void PyConsole_EnhEditor::extractCommon(const std::vector<QString> & matches, QString & result) const
+void PyConsole_EnhEditor::extractCommon(const QStringList& matches, QString& result) const
 {
   result = "";
   int charIdx = 0;
index c18738f29d2e59eb6bf7c1bdbdb6be4936541127..546ea98fc11099641b5ed83698fb07987653e56a 100644 (file)
 #define PYCONSOLE_ENHEDITOR_H_
 
 #include "PyConsole.h"
-
 #include "PyConsole_Editor.h"
+
 #include <QObject>
 #include <queue>
 
-class PyConsole_EnhInterp;
-
 /**
  * Enhanced Python editor handling tab completion.
  */
@@ -38,7 +36,7 @@ class PYCONSOLE_EXPORT PyConsole_EnhEditor: public PyConsole_Editor
   Q_OBJECT;
 
 public:
-  PyConsole_EnhEditor(PyConsole_EnhInterp * interp, QWidget * parent=0);
+  PyConsole_EnhEditor(PyConsole_Interp* interp, QWidget* parent = 0);
   virtual ~PyConsole_EnhEditor() {}
 
 signals:
@@ -83,14 +81,14 @@ protected:
   virtual void handleTab();
   virtual void handleBackTab();
   virtual void clearCompletion();
-  virtual void formatCompletion(const std::vector<QString> & matches, QString & result) const;
+  virtual void formatCompletion(const QStringList& matches, QString& result) const;
   virtual QString formatDocHTML(const QString & doc) const;
 
   virtual void multilinePaste(const QString & s);
   virtual void multiLineProcessNextLine();
 
 private:
-  void extractCommon(const std::vector<QString> & matches, QString & result) const;
+  void extractCommon(const QStringList& matches, QString& result) const;
 
 };
 
index 1f5defe0714bde0bcf29d7593ffcae097c4fcab9..eb5cb2705d1c18724ba74a5c590c10edc9556e5b 100644 (file)
@@ -37,6 +37,31 @@ static const char * tmp_k[] = {"and",  "as", "assert", "break",  "class",
 const std::vector<QString> PyConsole_EnhInterp::PYTHON_KEYWORDS = \
       std::vector<QString>(tmp_k, tmp_k+sizeof(tmp_k)/sizeof(tmp_k[0]));
 
+/*!
+  \brief Constructor
+*/
+PyConsole_EnhInterp::PyConsole_EnhInterp()
+  : PyConsole_Interp()
+{
+}
+
+/*!
+  \brief Destructor
+*/
+PyConsole_EnhInterp::~PyConsole_EnhInterp()
+{
+}
+
+QStringList PyConsole_EnhInterp::getLastMatches() const
+{
+  return _last_matches;
+}
+
+QString PyConsole_EnhInterp::getDocStr() const
+{
+  return _doc_str;
+}
+
 /*!
   \brief Run Python dir() command and saves the result internally in _lastPy
   \param dirArgument Python expression to pass to the dir command. The parsing of what the
@@ -45,7 +70,7 @@ const std::vector<QString> PyConsole_EnhInterp::PYTHON_KEYWORDS = \
   the user types "a_string_variable.rsp <TAB>", this is "rsp".
   \return command exit status - 0 = success
 */
-int PyConsole_EnhInterp::runDirCommand(const QString & dirArgument, const QString & startMatch)
+int PyConsole_EnhInterp::runDirCommand(const QString& dirArgument, const QString& startMatch)
 {
   int ret;
   std::vector<QString> v;
@@ -99,8 +124,9 @@ int PyConsole_EnhInterp::runDirCommand(const QString & dirArgument, const QStrin
  * @return -1 if the call to dir() or the parsing of the result failed, 0 otherwise.
  */
 int PyConsole_EnhInterp::runDirAndExtract(const QString& dirArgument,
-       const QString & startMatch, std::vector<QString> & result,
-       bool discardSwig) const
+                                         const QString& startMatch,
+                                         QStringList& result,
+                                         bool discardSwig) const
 {
   QRegExp re("^[A-Z].+_[A-Z]+[a-z]+.+$");  // discard SWIG static method, e.g. MEDCouplingUMesh_Blabla
   QString command("dir(" + dirArgument + ")");
@@ -146,9 +172,6 @@ int PyConsole_EnhInterp::runDirAndExtract(const QString& dirArgument,
  */
 void PyConsole_EnhInterp::clearCompletion()
 {
-  _last_matches.resize(0);
-  _doc_str = QString("");
+  _last_matches.clear();
+  _doc_str = "";
 }
-
-
-
index 4b16aa369c6330d8592c37e6bb08f70c4c040a4f..42c0ab35d9d4e576c1734c462ec5e0fd3537b0d9 100644 (file)
 class PYCONSOLE_EXPORT PyConsole_EnhInterp: public PyConsole_Interp
 {
 public:
-  PyConsole_EnhInterp()
-    : PyConsole_Interp(), _last_matches(0), _doc_str("")
-    {}
+  PyConsole_EnhInterp();
+  virtual ~PyConsole_EnhInterp();
 
-  virtual ~PyConsole_EnhInterp() {}
-
-  const std::vector<QString>& getLastMatches() const { return _last_matches; }
-  const QString & getDocStr() const                  { return _doc_str; }
+  virtual QStringList getLastMatches() const;
+  virtual QString getDocStr() const;
 
   virtual int runDirCommand(const QString& dirArgument, const QString& startMatch);
   virtual void clearCompletion();
@@ -55,13 +52,12 @@ protected:
   static const std::vector<QString> PYTHON_KEYWORDS;
 
   /** Last computed matches */
-  std::vector<QString> _last_matches;
+  QStringList _last_matches;
   /** Doc string of the first match - when only one match it will be displayed by the Editor*/
   QString _doc_str;
 
-  virtual int runDirAndExtract(const QString& dirArgument, const QString & startMatch,
-      std::vector<QString> & result, bool discardSwig=true) const;
-
+  virtual int runDirAndExtract(const QString& dirArgument, const QString& startMatch,
+                              QStringList& result, bool discardSwig=true) const;
 };
 
 #endif /* PYCONSOLE_ENHINTERP_H_ */
index 01c94fe20953b5c1012027d729682f9fb922fefd..e1365760a011ccc71636904297b458daf7a65ccd 100644 (file)
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-
-//  SALOME SALOMEGUI : implementation of desktop and GUI kernel
 //  File   : PyConsole_Interp.cxx
 //  Author : Nicolas REJNERI, Adrien BRUNETON
-//  Module : SALOME
-//
+
 #include "PyConsole_Interp.h"
 
 /*!
   Creates new python interpreter.
 */
 PyConsole_Interp::PyConsole_Interp(): PyInterp_Interp()
-{}
+{
+}
 
 /*!
   \brief Destructor.
 
   Does nothing for the moment.
 */
-PyConsole_Interp::~PyConsole_Interp() { }
+PyConsole_Interp::~PyConsole_Interp()
+{
+}
 
 /*! Sets the variable "__IN_SALOME_GUI_CONSOLE" to True.
 * This is not attached to a module (like salome_iapp.IN_SALOME_GUI_CONSOLE)
@@ -72,3 +72,22 @@ int PyConsole_Interp::afterRun()
 {
   return PyRun_SimpleString("__builtins__.__IN_SALOME_GUI_CONSOLE=False");
 }
+
+QStringList PyConsole_Interp::getLastMatches() const
+{
+  return QStringList();
+}
+
+QString PyConsole_Interp::getDocStr() const
+{
+  return QString();
+}
+
+int PyConsole_Interp::runDirCommand(const QString&, const QString& )
+{
+  return 0;
+}
+
+void PyConsole_Interp::clearCompletion()
+{
+}
index 5434e481347a9f00ef40b54d4e85c42362caf924..31e8f7e97a66c6167e5a203c9e66381e5f0d40a8 100644 (file)
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-
-//  SALOME SALOMEGUI : implementation of desktop and GUI kernel
 //  File   : PyConsole_Interp.h
 //  Author : Nicolas REJNERI, Adrien BRUNETON
-//  Module : SALOME
-//
+
 #ifndef PYCONSOLE_INTERP_H
 #define PYCONSOLE_INTERP_H
 
 #include "PyConsole.h"
+#include "PyInterp_Interp.h"   /// !!! WARNING !!! THIS INCLUDE MUST BE VERY FIRST !!!
 
-#include <PyInterp_Interp.h>   /// !!! WARNING !!! THIS INCLUDE MUST BE VERY FIRST !!!
+#include <QStringList>
 
 class PYCONSOLE_EXPORT PyConsole_Interp : public PyInterp_Interp
 {
@@ -40,6 +38,12 @@ public:
 
   virtual int afterRun();
   virtual int beforeRun();
+
+  virtual QStringList getLastMatches() const;
+  virtual QString getDocStr() const;
+
+  virtual int runDirCommand(const QString&, const QString&);
+  virtual void clearCompletion();
 };
 
 #endif // PYCONSOLE_INTERP_H
index 97bf7f2df41d5ade45bc41a4899d665e3ef5ee3a..12a5e612db80fed42db3991d891f3dfdcdcbfd18 100644 (file)
 // Created on: 3 avr. 2013
 
 #include "PyConsole_Request.h"
-
-#include "PyInterp_Event.h"
+#include "PyConsole_Interp.h"
 #include "PyConsole_Event.h"
-#include "PyConsole_EnhInterp.h"
-#include "PyConsole_EnhEditor.h"
+#include "PyInterp_Event.h"
 
 #include <QCoreApplication>
 
  * @param sync
  */
 ExecCommand::ExecCommand( PyInterp_Interp*        theInterp,
-               const QString&          theCommand,
-               PyConsole_Editor*       theListener,
-               bool                    sync )
-    : PyInterp_LockRequest( theInterp, theListener, sync ),
-      myCommand( theCommand ), myState( PyInterp_Event::ES_OK )
-  {}
+                         const QString&          theCommand,
+                         QObject*                theListener,
+                         bool                    theSync )
+  : PyInterp_LockRequest( theInterp, theListener, theSync ),
+    myCommand( theCommand ), myState( PyInterp_Event::ES_OK )
+{}
 
 /**
  * Execute the command by calling the run() method of the embedded interpreter.
@@ -50,13 +48,13 @@ ExecCommand::ExecCommand( PyInterp_Interp*        theInterp,
 void ExecCommand::execute()
 {
   if ( myCommand != "" )
-    {
-      int ret = getInterp()->run( myCommand.toUtf8().data() );
-      if ( ret < 0 )
-        myState = PyInterp_Event::ES_ERROR;
-      else if ( ret > 0 )
-        myState = PyInterp_Event::ES_INCOMPLETE;
-    }
+  {
+    int ret = getInterp()->run( myCommand.toUtf8().data() );
+    if ( ret < 0 )
+      myState = PyInterp_Event::ES_ERROR;
+    else if ( ret > 0 )
+      myState = PyInterp_Event::ES_INCOMPLETE;
+  }
 }
 
 /**
@@ -80,13 +78,13 @@ QEvent* ExecCommand::createEvent()
   \param theListener widget to get the notification messages
   \param sync        if True the request is processed synchronously
 */
-CompletionCommand::CompletionCommand( PyConsole_EnhInterp*  theInterp,
-               const QString&          input,
-               const QString&         startMatch,
-               PyConsole_EnhEditor*           theListener,
-               bool                    sync)
-     : PyInterp_LockRequest( theInterp, theListener, sync ),
-       _tabSuccess(false), _dirArg(input), _startMatch(startMatch)
+CompletionCommand::CompletionCommand( PyInterp_Interp*   theInterp,
+                                     const QString&     theInput,
+                                     const QString&     theStartMatch,
+                                     QObject*           theListener,
+                                     bool               theSync )
+  : PyInterp_LockRequest( theInterp, theListener, theSync ),
+    _tabSuccess(false), _dirArg(theInput), _startMatch(theStartMatch)
 {}
 
 /**
@@ -95,12 +93,8 @@ CompletionCommand::CompletionCommand( PyConsole_EnhInterp*  theInterp,
  */
 void CompletionCommand::execute()
 {
-  PyConsole_EnhInterp * interp = static_cast<PyConsole_EnhInterp *>(getInterp());
-    int ret = interp->runDirCommand( _dirArg,  _startMatch);
-    if (ret == 0)
-      _tabSuccess = true;
-    else
-      _tabSuccess = false;
+  int ret = static_cast<PyConsole_Interp*>(getInterp())->runDirCommand( _dirArg,  _startMatch );
+  _tabSuccess = ret == 0;
 }
 
 /**
@@ -110,9 +104,5 @@ void CompletionCommand::execute()
 QEvent* CompletionCommand::createEvent()
 {
   int typ = _tabSuccess ? PyInterp_Event::ES_TAB_COMPLETE_OK : PyInterp_Event::ES_TAB_COMPLETE_ERR;
-
   return new PyInterp_Event( typ, this);
 }
-
-
-
index c2f22ff432bad9f9efc245bb20e2e32f344fe141..5605cc7fa5fc45690eab7990c66a15d8f8d3c400 100644 (file)
@@ -23,7 +23,6 @@
 #ifndef PYCONSOLE_REQUEST_H_
 #define PYCONSOLE_REQUEST_H_
 
-#include "PyConsole.h"
 #include "PyInterp_Request.h"
 
 #include <vector>
@@ -31,7 +30,6 @@
 #include <QEvent>
 
 class PyInterp_Interp;
-class PyConsole_Editor;
 
 /*!
   \class ExecCommand
@@ -52,8 +50,8 @@ public:
   */
   ExecCommand( PyInterp_Interp*        theInterp,
                const QString&          theCommand,
-               PyConsole_Editor*       theListener,
-               bool                    sync = false );
+               QObject*                theListener,
+               bool                    theSync = false );
 
 protected:
   /*!
@@ -73,17 +71,14 @@ private:
   int     myState;     //!< Python command execution status
 };
 
-class PyConsole_EnhInterp;
-class PyConsole_EnhEditor;
-
 class CompletionCommand : public PyInterp_LockRequest
 {
 public:
-  CompletionCommand( PyConsole_EnhInterp*      theInterp,
-               const QString&          input,
-               const QString&          startMatch,
-               PyConsole_EnhEditor*    theListener,
-               bool                    sync = false );
+  CompletionCommand( PyInterp_Interp*     theInterp,
+                    const QString&       theInput,
+                    const QString&       theStartMatch,
+                    QObject*             theListener,
+                    bool                 theSync = false );
 
 
 protected:
@@ -99,7 +94,6 @@ protected:
 
   virtual void execute();
   virtual QEvent* createEvent();
-
 };
 
 #endif /* PYCONSOLE_REQUEST_H_ */
index c9e8d72e1cedf94cf07ab3505ed4fc463b1c8138..c142eca0b827dad9e86f3eb665e470f2ef8293e0 100644 (file)
@@ -1112,7 +1112,7 @@ QWidget* SalomeApp_Application::createWindow( const int flag )
 #ifndef DISABLE_PYCONSOLE
   else if ( flag == WT_PyConsole )
   {
-    PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), new SalomeApp_PyInterp() );
+    PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), getPyInterp() );
     pyCons->setObjectName( "pythonConsole" );
     pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
     pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
@@ -2124,3 +2124,13 @@ bool SalomeApp_Application::checkExistingDoc()
   }
   return result;
 }
+
+
+#ifndef DISABLE_PYCONSOLE
+
+PyConsole_Interp* SalomeApp_Application::createPyInterp()
+{
+  return new SalomeApp_PyInterp();
+}
+
+#endif // DISABLE_PYCONSOLE
index b9833a1dcdb797d96bd2f549adbfcf19db157cb6..aeee6dcb2be248afca72485c37eba98dc00aefad 100644 (file)
@@ -168,6 +168,7 @@ protected:
 
 #ifndef DISABLE_PYCONSOLE
   bool                                updateStudy();
+  virtual PyConsole_Interp*           createPyInterp();
 #endif
 
   virtual void                        afterCloseDoc();
index 5274494994295f72def591034ff1e459f65d9fd3..9611f2ff4be00e1214ca8f0623d40a91fb83539c 100644 (file)
@@ -23,7 +23,6 @@
 
 #ifndef DISABLE_PYCONSOLE
   #include <PyConsole_Interp.h> // this include must be first (see PyInterp_base.h)!
-  #include <PyConsole_Console.h>
 #endif
 
 #include "SalomeApp_DoubleSpinBox.h"
@@ -438,8 +437,7 @@ SalomeApp_DoubleSpinBox::SearchState SalomeApp_DoubleSpinBox::findVariable( cons
           if( studyDS->IsString( aName ) )
             {
 #ifndef DISABLE_PYCONSOLE
-              PyConsole_Console* pyConsole = app->pythonConsole();
-              PyConsole_Interp* pyInterp = pyConsole->getInterp();
+              PyConsole_Interp* pyInterp = app->getPyInterp();
               PyLockWrapper aLock; // Acquire GIL
               std::string command;
               command  = "import salome_notebook ; ";
index 2e8bcc78d90f607da37a2668af3fec4d428a157f..b5cc01765d6e117a9197071ce65a46f1c5d7a525 100644 (file)
@@ -23,7 +23,6 @@
 
 #ifndef DISABLE_PYCONSOLE
   #include <PyConsole_Interp.h> //this include must be first (see PyInterp_base.h)!
-  #include <PyConsole_Console.h>
 #endif
 
 #include "SalomeApp_IntSpinBox.h"
@@ -386,8 +385,7 @@ SalomeApp_IntSpinBox::SearchState SalomeApp_IntSpinBox::findVariable( const QStr
           if( studyDS->IsString( aName ) )
             {
 #ifndef DISABLE_PYCONSOLE
-              PyConsole_Console* pyConsole = app->pythonConsole();
-              PyConsole_Interp* pyInterp = pyConsole->getInterp();
+              PyConsole_Interp* pyInterp = app->getPyInterp();
               PyLockWrapper aLock; // Acquire GIL
               std::string command;
               command  = "import salome_notebook ; ";
index b5ecb767ad43ae4563cf3331481cb11da9def5fb..242aae2ca3d2b39c1df8b3fd09868ea00e93b873 100644 (file)
@@ -285,7 +285,7 @@ bool NoteBook_TableRow::IsValidStringValue(const QString theValue)
 
   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
   PyConsole_Console* pyConsole = app->pythonConsole();
-  PyConsole_Interp* pyInterp = pyConsole->getInterp();
+  PyConsole_Interp* pyInterp = app->getPyInterp();
   PyLockWrapper aLock; // Acquire GIL
   std::string command = "import salome_notebook ; ";
   command += "salome_notebook.checkThisNoteBook(";
@@ -459,7 +459,7 @@ bool NoteBook_Table::IsValid() const
 
   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
   PyConsole_Console* pyConsole = app->pythonConsole();
-  PyConsole_Interp* pyInterp = pyConsole->getInterp();
+  PyConsole_Interp* pyInterp = app->getPyInterp();
   PyLockWrapper aLock; // Acquire GIL
   std::string command = "import salome_notebook ; ";
   command += "salome_notebook.checkThisNoteBook(";
index bf7bd8d500083006dbfdc8dc30d882969143f511..a0b6a3ec2b8dce607e4ad71390e159dfcbdf9f77 100755 (executable)
@@ -31,8 +31,9 @@
 
 class SalomeApp_PyInterp : public PyConsole_EnhInterp
 {
+  friend class SalomeApp_Application;
+
 public:
-  SalomeApp_PyInterp();
   virtual ~SalomeApp_PyInterp();
 
   virtual void initPython();
@@ -40,6 +41,7 @@ public:
   virtual void closeContext();
 
 protected:
+  SalomeApp_PyInterp();
   virtual int  beforeRun();
 
 private:
index 2934889368ae8446a0f7c327f85641c628322024..ab6166997d6d3e58ccdbaa1433310d69d15368c4 100644 (file)
@@ -49,7 +49,6 @@
 
 #ifndef DISABLE_PYCONSOLE
   #include "SalomeApp_PyInterp.h" // WARNING! This include must be the first!
-  #include <PyConsole_Console.h>
 #endif
 
 #include "utilities.h"
@@ -741,8 +740,7 @@ void SalomeApp_Study::closeDocument(bool permanently)
       desk->blockSignals( isBlocked );
 #ifndef DISABLE_PYCONSOLE
       SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
-      if( app->pythonConsole() )
-        app->pythonConsole()->getInterp()->destroy();
+      app->getPyInterp()->destroy();
 #endif
     }
     SALOMEDSClient_Study* aStudy = 0;