Salome HOME
IPAL53103: Mesh visualization performance problem
[modules/gui.git] / src / PyConsole / PyConsole_Request.h
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Adrien Bruneton (CEA/DEN)
20 // Created on: 3 avr. 2013
21
22
23 #ifndef PYCONSOLE_REQUEST_H_
24 #define PYCONSOLE_REQUEST_H_
25
26 #include "PyInterp_Request.h"
27
28 #include <vector>
29 #include <QString>
30 #include <QEvent>
31
32 class PyInterp_Interp;
33
34 /*!
35   \class ExecCommand
36   \brief Python command execution request.
37   \internal
38 */
39 class ExecCommand : public PyInterp_LockRequest
40 {
41 public:
42   /*!
43     \brief Constructor.
44
45     Creates new python command execution request.
46     \param theInterp   python interpreter
47     \param theCommand  python command
48     \param theListener widget to get the notification messages
49     \param sync        if True the request is processed synchronously
50   */
51   ExecCommand( PyInterp_Interp*        theInterp,
52                const QString&          theCommand,
53                QObject*                theListener,
54                bool                    theSync = false );
55
56 protected:
57   /*!
58     \brief Execute the python command in the interpreter and
59            get its execution status.
60   */
61   virtual void execute();
62
63   /*!
64     \brief Create and return a notification event.
65     \return new notification event
66   */
67   virtual QEvent* createEvent();
68
69 private:
70   QString myCommand;   //!< Python command
71   int     myState;     //!< Python command execution status
72 };
73
74 class CompletionCommand : public PyInterp_LockRequest
75 {
76 public:
77   CompletionCommand( PyInterp_Interp*     theInterp,
78                      const QString&       theInput,
79                      const QString&       theStartMatch,
80                      QObject*             theListener,
81                      bool                 theSync = false );
82
83
84 protected:
85   /** List of separators identifying the last parsable token for completion */
86   static const std::vector<QString> SEPARATORS;
87
88   /** String to be passed to the dir() command */
89   QString _dirArg;
90   /** Begining of the command (as typed by the user) */
91   QString _startMatch;
92   /** was the completion command successful */
93   bool _tabSuccess;
94
95   virtual void execute();
96   virtual QEvent* createEvent();
97 };
98
99 #endif /* PYCONSOLE_REQUEST_H_ */