Disable trace observers when tracing python state in cpstate.py

This is the same as the bugfix that was applied to smstate.py in
commit b27145eb9aa

Change-Id: I2e5cd64c1f224cc8b788a02e5f6008c59c0591e5
Make sure the paraview module is always initialized by pqPythonManager

If Python was initialized before the pqPythonManager was constructed then
the paraview module would not be imported as it is supposed to.  This
could happen if a startup plugin initialized Python before the
pqPythonManager is created, which can be the case with Python based
plugins.

Change-Id: I3a79547ce84d19773d95725e7fc1b7c6b99cb64c
Add a call to prompt() during the python shell startup

This prints the ">>>" prompt before printing the status message so that
the user will see:

>>> from paraview.simple import *

Change-Id: I477bf59677400bf2073b9812afe8c7558d2796ef
Don't print a newline when executing a python command in the console.

Printing a newline forced a new prompt to be printed even if the executed
python code did not generate any stdout.  The python console now uses
a flag this->Prompted to determien whether or not displaying the prompt
is required.

Change-Id: I8d28012b8281934961f2d8c78e91102b5f78c9f3
Execute python code in the context of the interactive console.

The function pqPythonShell::executeScript() is used to programmatically
execute python code.  This is used when running python scripts the user
selects with the Run Script button.  These should run in the console
context.

Code executed with vtkPythonInterpreter::RunSimpleString() will run in the
__main__ context which is now different from the ParaView python console.

The "from paraview.simple import *" statement is only executed in the
ParaView python console.

Change-Id: I5f957e6d60a6f77d37a6ed7c6b7cf1eec10fb517
Change the behavior of pqPythonShell::pushScript() to split over newlines

Previously, you could not paste multiline statements into the ParaView
python console.  This commit changes the behavior of the pushScript()
function so that it splits the script code over the newline character
and pushes each line separately.

This does change the behavior of entering multiline statements: previously
pushScript() would attempt to detect the indent and start the next line
using the indent of the previous line.  This behavior has been removed.

The new behavior closely matches the behavior of the standard commandline
python interpreter.

Change-Id: I899ec69194a1cce3d82cefc2f13048aad8f81fec
Add a test for using the Python programmable filter with pvserver

Change-Id: I7413cba942cabc1bd9b5557964c7aa1224ca5750
Fix: in the programmable filter, delete the function before redefining it

This was a bug in the programmable filter.  If there was a syntax error
in the python script, then the python code that defined the RequestData
function (or other functions) would fail, and then the filter would
execute the previously defined version of the function.  The previously
defined version could have even been defined by a different programmable
filter.

In the future, the programmable filter could be refactored so that it
executes all code in a namespace (it could use the
vtkInteractivePythonConsole) which is cleaned up each time.  Currently,
it stores variables directly in the __main__ context.

Change-Id: Ieba0ca70396aa08fb7f8a8cc93aa4e2edc3f71c9
Fix the SetParameter API overloads of the vtkPythonProgrammableFilter

Commit fc8cabcd (April 2007) introduced a SetParameter function on the
programmable filter.  It added a string vector property to filter proxy
that could be used to set arbitrary parameter name/value pairs that would
be defined in the filter python script.

Commit 8311d712 (July 2011) introduced several SetParameter overloads so
that custom string, int, and double vector properties were supported.
This allowed proxy xml to declare custom properties on the python
programmable filter that would be presented in the GUI like regular
properties.  But, this commit also changed the behavior of the original
Parameter string vector property.

Commit 9176ba5c82 (March 2012) accidentally broke the SetParameter
overloads.

This commit (May 2013) fixes the SetParameter overloads and original
Parameter string vector property (but both cannot be used together).
This commit adds a test for the SetParameter API and adds an example
proxy xml file that demonstrates how to define a python programmable
filter with custom parameters.

Change-Id: I3583fbfdd7d9d442799c714bb2c34693d34ed2ea
Initialize Python before constructing the python console

Python was being initialized when executing code in the pqPythonShell
constructor. Instead, Python should be initialized explicitly by the
pqPythonManager before constructing the pqPythonDialog object.
The pqPythonShell does not need to handle the EnterEvent anymore.

Change-Id: Ib7d97929f989687194ab4a91f1fae6397eb4fc50
Remove pqPythonShell::initPythonInerpreter callback.

Now, the pyPythonManager calls pqPythonShell::setupInterpreter() after
the pqPythonShell has been created.  This way, the pyPythonShell does
not execute an python code in its constructor, but the pqPythonManager
guarantees that it is fully initialized after construction.

Executing python code in the constructor is bad because of the way stdout
is handled in a callback by the pqPythonManager, and using a timer to
initialize later is bad because the stdout won't be routed correctly
until after the timer callback.

This commit also removes the ExitEvent handling from the pyPythonShell
since ParaView only finializes Python once at exit, there is no need to
have a handler to reset the pyPythonShell.

Change-Id: Ib9b53f38f4b7fc558823dcb11c029554bd23828c
Remove unused methods in pqPythonManager

Change-Id: I6786ecfa3905e447c8926022f764cf2130067d63
Use the python main context instead of the interactive console for trace.

The record trace and trace state features can execute in the __main__
python context using vtkPythonInterpreter::RunSimpleString() instead
of executing in the context of the interactive console owned by the
pqPythonShell.

I can't think of a reason to prefer one context instead of the other, but
using the __main__ context simplifies the code in pqPythonManager.
In either case, the only variables written to the context is the imported
smtrace module name and the __smtraceString str object.

Change-Id: I5239067c9d95a27f9a5867fd075b4bc146c4da76
Remove the call to smtrace.print_trace from smstate.trace_state.

The print statement is unnecessary.  The trace is saved to a file, so the
printing is probably a remnant from development and debugging of smstate.

Change-Id: I626dcb1be4a745bec59e81e2b09e5824995107a5
Add the debug leaks view to ParaView

The debug leaks view is be shown as a top level widget on application
startup if the environment variable PV_DEBUG_LEAKS_VIEW is set.

pqPythonDebugLeaksView extends the vtkQtDebugLeaksView to add Python
capabilities to the debugger.  You can add references to tracked VTK
objects to the Python console for inspection.

Change-Id: I26918d9a499817ff5c75cef5dba82e5ba1de9ae7
Merge topic '13024-python-debug-leaks-view' into next

72cd55f Add the debug leaks view to ParaView
Merge topic '14151-python-refactoring' into next

7a6f910 Remove the call to smtrace.print_trace from smstate.trace_state.
fc79162 Use the python main context instead of the interactive console for trace.
11c7cde Remove unused methods in pqPythonManager
b8e68e6 Remove pqPythonShell::initPythonInerpreter callback.
1fc7abe Initialize Python before constructing the python console
d19f1fd Fix the SetParameter API overloads of the vtkPythonProgrammableFilter
e492636 Fix: in the programmable filter, delete the function before redefining it
afc3965 Add a test for using the Python programmable filter with pvserver
af99ee3 Change the behavior of pqPythonShell::pushScript() to split over newlines
c946500 Execute python code in the context of the interactive console.
7cbabb7 Don't print a newline when executing a python command in the console.
2ad7938 Add a call to prompt() during the python shell startup
00427e5 Make sure the paraview module is always initialized by pqPythonManager
a1fedb9 Disable trace observers when tracing python state in cpstate.py