* Must be called before executing a Python snippet in the shell. * Does several things: * 1. ensures that Python interpreter is initialized. * 2. ensures that the input/output streams are captured. */
| 111 | * 2. ensures that the input/output streams are captured. |
| 112 | */ |
| 113 | void begin() |
| 114 | { |
| 115 | assert(this->ExecutionCounter >= 0); |
| 116 | if (this->ExecutionCounter == 0) |
| 117 | { |
| 118 | assert(this->OldInstance == nullptr); |
| 119 | Q_EMIT this->Parent->executing(true); |
| 120 | |
| 121 | if (this->isInterpreterInitialized() == false) |
| 122 | { |
| 123 | this->initializeInterpreter(); |
| 124 | } |
| 125 | |
| 126 | this->OldInstance = vtkOutputWindow::GetInstance(); |
| 127 | vtkOutputWindow::SetInstance(this->MessageCapture); |
| 128 | this->OldCapture = vtkPythonInterpreter::GetCaptureStdin(); |
| 129 | vtkPythonInterpreter::SetCaptureStdin(true); |
| 130 | } |
| 131 | this->ExecutionCounter++; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Must match a `begin` and should be called when done with Python snippet |