Refactored Python View to remove dependence on matplotlib

In principal, image data to be displayed in a view render window could
be generated many different ways in Python - using matplotlib, OpenCV,
or even direct manipulation of a numpy array. In light of that, this
change decouples the Python View from matplotlib. Matplotlib may still
be used to generate images in the Python view with slight modification
to existing Python scripts used in the Python view.

From a user's perspective, the only changes to know about are how to
define the "render" function in the Python script. Previously, the
"render" function had the signature

  def render(view, figure)

where "view" is the Python View instance calling this function and
"figure" was a matplotlib figure that was set up by the view
automatically. The function was not expected to return a value.

Now the "render" function has the signature

  def render(view, width, height)

where "view" is still the Python View and the "width" and "height"
parameters are the width and height of the current view render
window. IMPORTANT - the function is now expected to return a
vtkImageData object containing the image content to display in the
view render window.

To generate an image from matplotlib, Figure and FigureCanvas
object need to be created the following way:

  from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
  from matplotlib.figure import Figure

  figure = Figure()
  figureCanvas = FigureCanvas(figure)
  figure.set_dpi(72)
  figure.set_size_inches(float(width)/72.0, float(height)/72.0)

This "figure" object can be used in the same way as the "figure"
argument in the previous signature of the "render" method.

A convenience function has been added to to the python_view module to
create a vtkImageData object from a matplotlib Figure object. It is
used as follows:

  from paraview import python_view
  vtk_image = python_view.figure_to_image(figure)

This refactoring has simplified the implementation of the Python View
dramatically. The matplotlib utilities are no longer needed with the
changes in the Python View. Furthermore, Python View is now available
whenever Python is enabled.

Change-Id: Ic41301f5f7492fa8f171570b03eff317c7faf108
Made python view dependent only on Python

Removed dependency on matplotlib.

Change-Id: I2896bec920f3ce0a7f6209c813b7752bce94a4aa
Removed Python View's dependency on matplotlib

Matplotlib is no longer necessary to use Python View.

Change-Id: Iff5713f5727ba295ae055bbc9cee8ea726a7c48b
Updated Python View tests for refactored Python View

Change-Id: I0c80d67a0749be0c134c5fff686f09b10dd6d0bd
Made test name more specific

Change-Id: I3e6d23c14ce4082fe163cae90896563f0cd8090a
Updated Python View baseline

Change-Id: I32a35a8b2ca5e560d8050bb84f0842d83b58a6e9
Added utility function numpy_to_image

This function converts 2D or 3D numpy arrays to vtkImageData
objects.

Change-Id: I9e23f161201c794f3ef122f3f8bf3c3a7b4b39da
Fixed the test to generate a valid image

Change-Id: I4d97ea635c54cef1c9a80699ffc704d2d2ef6139
Added utility function matplotlib_figure(width, height)

This saves on some boilerplate for setting up matplotlib figures in
Python views.

Removed some unneeded semicolons.

Change-Id: I1036d88eb979dff73aeb0c4c6ea855091e14ab7a
Added comparison against baseline for Python View test

Change-Id: Icd69b17bd9cdfd992bc19356301cf6717fa4d61e
Removed dependency of pqPythonView on matplotlib

It remains dependent on PARAVIEW_ENABLE_PYTHON being on.

Change-Id: Ia519c9bbf5a2ba559b8c62e6d79c065ccdde23e4
Added two Python View tests

One tests creation of a view image from a numpy array and the other
tests creation of an image using only VTK. Added baselines as well.

Change-Id: I03ce0abaa029ebbc8284712e3dde11f13a51865f
Removed some commented out code

Change-Id: I5560b1f7e9502103c2331d84a383e3374a014341
Removed unnecessary explicit loading of test baseline

Change-Id: Ie1f20192654d97ee5e51958c59f14220d70a8862
Moved most of the code calling Python functions to Python side

The scripts that invoked the user-defined functions were getting long
and awkward to call from the C++ side, so they have moved to the
Python side.

In addition, added backwards compatibility support for calling
old-style render() functions so that no modifications to existing
scripts are required. This works by checking the number of arguments
required by the defined render() function. If the number of arguments
is two, an old-style render() function is assumed. If the number of
arguments is three, the new-style render() function is assumed.

Change-Id: I09d8a10d0fdc0573de6d6cfc7bcc8523c5fb43f1
Evaluate script within a unique Python dictionary

If there were two or more Python View instances, the top-level
functions and variables from the most-recently evaluated Python View
script would clobber the functions and variables from the other Python
Views. To fix this, now each Python View script is evaluated in the
context of a unique Python dictionary copied from the global
dictionary returned by the globals() built-in function. This prevents
any clobbering of function definitions between different instances of
the vtkPythonView class.

To simplify calling these functions from the C++ side, the utility
functions call_render() and call_setup_data() in python_view.py
now take a reference to the function that should be evaluated.

Change-Id: I7fe294ea40508c4fc0c1bd18706c156da7f08a2b

Change-Id: I8d5304905cd1c69fb6cc390718ff41da2a718660
Reset image data in the vtkPythonView before each render

If this is not done, the previous successfully generated image may
still be displayed.

In addition, the Python environment is now reset prior to evaluating
the python script to clear out any definitions set in prior
evaluations of different verions of the script. For example, one could
define a render() method in the script, then set the script to the
empty string. Without resetting the Python environment, the render()
method would still be defined, which is unexpected stateful behavior.

Change-Id: I8979d8c2f9ec1657c7a84292e18d77147d947647
Cleaned up vtkPythonView code

- Removed unused helper code
- Got rid of GenerateImage() method that wasn't really needed.

Change-Id: I03ee11215ec713b5a84c3e4d62b5d9d252b2467f
Merge topic 'generalize_python_view' into next

4b9e10ac Cleaned up vtkPythonView code
4b9d452b Reset image data in the vtkPythonView before each render
b35b18da Evaluate script within a unique Python dictionary
3ada95a9 Moved most of the code calling Python functions to Python side
a6bba0ce Removed unnecessary explicit loading of test baseline
20df572a Removed some commented out code
64d65098 Added two Python View tests
2a8174ca Removed dependency of pqPythonView on matplotlib
8229c50e Added comparison against baseline for Python View test
15268405 Added utility function matplotlib_figure(width, height)
7613571c Fixed the test to generate a valid image
9a82c9fe Added utility function numpy_to_image
96c67cf9 Updated Python View baseline
a0adf856 Made test name more specific
55b039ae Updated Python View tests for refactored Python View
007f10e1 Removed Python View's dependency on matplotlib
...