Skip to content

Commit

Permalink
Removed unused _wxagg extension.
Browse files Browse the repository at this point in the history
svn path=/trunk/matplotlib/; revision=8702
  • Loading branch information
efiring committed Sep 16, 2010
1 parent d8c86dc commit 89435dd
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 508 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2010-09-15 Remove unused _wxagg extension. - EF

2010-08-25 Add new framework for doing animations with examples.- RM

2010-08-21 Remove unused and inappropriate methods from Tick classes:
Expand Down
101 changes: 2 additions & 99 deletions lib/matplotlib/backends/backend_wxagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,78 +128,12 @@ def new_figure_manager(num, *args, **kwargs):
return figmgr


#
# agg/wxPython image conversion functions (wxPython <= 2.6)
#

def _py_convert_agg_to_wx_image(agg, bbox):
"""
Convert the region of the agg buffer bounded by bbox to a wx.Image. If
bbox is None, the entire buffer is converted.
Note: agg must be a backend_agg.RendererAgg instance.
"""
image = wx.EmptyImage(int(agg.width), int(agg.height))
image.SetData(agg.tostring_rgb())

if bbox is None:
# agg => rgb -> image
return image
else:
# agg => rgb -> image => bitmap => clipped bitmap => image
return wx.ImageFromBitmap(_clipped_image_as_bitmap(image, bbox))


def _py_convert_agg_to_wx_bitmap(agg, bbox):
"""
Convert the region of the agg buffer bounded by bbox to a wx.Bitmap. If
bbox is None, the entire buffer is converted.
Note: agg must be a backend_agg.RendererAgg instance.
"""
if bbox is None:
# agg => rgb -> image => bitmap
return wx.BitmapFromImage(_py_convert_agg_to_wx_image(agg, None))
else:
# agg => rgb -> image => bitmap => clipped bitmap
return _clipped_image_as_bitmap(
_py_convert_agg_to_wx_image(agg, None),
bbox)


def _clipped_image_as_bitmap(image, bbox):
"""
Convert the region of a wx.Image bounded by bbox to a wx.Bitmap.
"""
l, b, width, height = bbox.bounds
r = l + width
t = b + height

srcBmp = wx.BitmapFromImage(image)
srcDC = wx.MemoryDC()
srcDC.SelectObject(srcBmp)

destBmp = wx.EmptyBitmap(int(width), int(height))
destDC = wx.MemoryDC()
destDC.SelectObject(destBmp)

destDC.BeginDrawing()
x = int(l)
y = int(image.GetHeight() - t)
destDC.Blit(0, 0, int(width), int(height), srcDC, x, y)
destDC.EndDrawing()

srcDC.SelectObject(wx.NullBitmap)
destDC.SelectObject(wx.NullBitmap)

return destBmp


#
# agg/wxPython image conversion functions (wxPython >= 2.8)
#

def _py_WX28_convert_agg_to_wx_image(agg, bbox):
def _convert_agg_to_wx_image(agg, bbox):
"""
Convert the region of the agg buffer bounded by bbox to a wx.Image. If
bbox is None, the entire buffer is converted.
Expand All @@ -216,7 +150,7 @@ def _py_WX28_convert_agg_to_wx_image(agg, bbox):
return wx.ImageFromBitmap(_WX28_clipped_agg_as_bitmap(agg, bbox))


def _py_WX28_convert_agg_to_wx_bitmap(agg, bbox):
def _convert_agg_to_wx_bitmap(agg, bbox):
"""
Convert the region of the agg buffer bounded by bbox to a wx.Bitmap. If
bbox is None, the entire buffer is converted.
Expand Down Expand Up @@ -262,34 +196,3 @@ def _WX28_clipped_agg_as_bitmap(agg, bbox):

return destBmp


def _use_accelerator(state):
"""
Enable or disable the WXAgg accelerator, if it is present and is also
compatible with whatever version of wxPython is in use.
"""
global _convert_agg_to_wx_image
global _convert_agg_to_wx_bitmap

if getattr(wx, '__version__', '0.0')[0:3] < '2.8':
# wxPython < 2.8, so use the C++ accelerator or the Python routines
if state and _wxagg is not None:
_convert_agg_to_wx_image = _wxagg.convert_agg_to_wx_image
_convert_agg_to_wx_bitmap = _wxagg.convert_agg_to_wx_bitmap
else:
_convert_agg_to_wx_image = _py_convert_agg_to_wx_image
_convert_agg_to_wx_bitmap = _py_convert_agg_to_wx_bitmap
else:
# wxPython >= 2.8, so use the accelerated Python routines
_convert_agg_to_wx_image = _py_WX28_convert_agg_to_wx_image
_convert_agg_to_wx_bitmap = _py_WX28_convert_agg_to_wx_bitmap


# try to load the WXAgg accelerator
try:
import _wxagg
except ImportError:
_wxagg = None

# if it's present, use it
_use_accelerator(True)
8 changes: 0 additions & 8 deletions setup.cfg.template
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ tag_svn_revision = 1
#gtk = False
#gtkagg = False
#tkagg = False
#wxagg = False
#macosx = False

[rc_options]
Expand All @@ -74,10 +73,3 @@ tag_svn_revision = 1
#
#backend = Agg
#
# The numerix module was historically used to provide
# compatibility between the Numeric, numarray, and NumPy array
# packages. Now that NumPy has emerge as the universal array
# package for python, numerix is not really necessary and is
# maintained to provide backward compatibility. Do not change
# this unless you have a compelling reason to do so.
#numerix = numpy
15 changes: 2 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@

import glob
from distutils.core import setup
from setupext import build_agg, build_gtkagg, build_tkagg, build_wxagg,\
from setupext import build_agg, build_gtkagg, build_tkagg,\
build_macosx, build_ft2font, build_image, build_windowing, build_path, \
build_contour, build_delaunay, build_nxutils, build_gdk, \
build_ttconv, print_line, print_status, print_message, \
print_raw, check_for_freetype, check_for_libpng, check_for_gtk, \
check_for_tk, check_for_wx, check_for_macosx, check_for_numpy, \
check_for_tk, check_for_macosx, check_for_numpy, \
check_for_qt, check_for_qt4, check_for_cairo, \
check_provide_pytz, check_provide_dateutil,\
check_for_dvipng, check_for_ghostscript, check_for_latex, \
Expand Down Expand Up @@ -156,17 +156,6 @@ def chop_package(fname):
build_tkagg(ext_modules, packages)
rc['backend'] = 'TkAgg'

if options['build_wxagg']:
if check_for_wx() or (options['build_wxagg'] is True):
options['build_agg'] = 1
import wx
if getattr(wx, '__version__', '0.0')[0:3] < '2.8' :
build_wxagg(ext_modules, packages)
wxagg_backend_status = "yes"
else:
print_message("WxAgg extension not required for wxPython >= 2.8")
rc['backend'] = 'WXAgg'

hasgtk = check_for_gtk()
if options['build_gtk']:
if hasgtk or (options['build_gtk'] is True):
Expand Down
115 changes: 0 additions & 115 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
BUILT_IMAGE = False
BUILT_MACOSX = False
BUILT_TKAGG = False
BUILT_WXAGG = False
BUILT_WINDOWING = False
BUILT_CONTOUR = False
BUILT_DELAUNAY = False
Expand All @@ -127,7 +126,6 @@
'build_gtk': 'auto',
'build_gtkagg': 'auto',
'build_tkagg': 'auto',
'build_wxagg': 'auto',
'build_macosx': 'auto',
'build_image': True,
'build_windowing': True,
Expand Down Expand Up @@ -166,9 +164,6 @@
try: options['build_tkagg'] = config.getboolean("gui_support", "tkagg")
except: options['build_tkagg'] = 'auto'

try: options['build_wxagg'] = config.getboolean("gui_support", "wxagg")
except: options['build_wxagg'] = 'auto'

try: options['build_macosx'] = config.getboolean("gui_support", "macosx")
except: options['build_macosx'] = 'auto'

Expand Down Expand Up @@ -710,97 +705,6 @@ def add_pygtk_flags(module):
if sys.platform == 'win32' and win32_compiler == 'msvc' and 'm' in module.libraries:
module.libraries.remove('m')


def check_for_wx():
gotit = False
explanation = None
try:
import wx
except ImportError:
explanation = 'wxPython not found'
else:
if getattr(wx, '__version__', '0.0')[0:3] >= '2.8':
print_status("wxPython", wx.__version__)
return True
elif sys.platform == 'win32' and win32_compiler == 'mingw32':
explanation = "The wxAgg extension can not be built using the mingw32 compiler on Windows, since the default wxPython binary is built using MS Visual Studio"
else:
wxconfig = find_wx_config()
if wxconfig is None:
explanation = """
WXAgg's accelerator requires `wx-config'.
The `wx-config\' executable could not be located in any directory of the
PATH environment variable. If you want to build WXAgg, and wx-config is
in some other location or has some other name, set the WX_CONFIG
environment variable to the full path of the executable like so:
export WX_CONFIG=/usr/lib/wxPython-2.6.1.0-gtk2-unicode/bin/wx-config
"""
elif not check_wxpython_broken_macosx104_version(wxconfig):
explanation = 'WXAgg\'s accelerator not building because a broken wxPython (installed by Apple\'s Mac OS X) was found.'
else:
gotit = True

if gotit:
module = Extension("test", [])
add_wx_flags(module, wxconfig)
if not find_include_file(
module.include_dirs,
os.path.join("wx", "wxPython", "wxPython.h")):
explanation = ("Could not find wxPython headers in any of %s" %
", ".join(["'%s'" % x for x in module.include_dirs]))

if gotit:
print_status("wxPython", wx.__version__)
else:
print_status("wxPython", "no")
if explanation is not None:
print_message(explanation)
return gotit

def find_wx_config():
"""If the WX_CONFIG environment variable has been set, returns it value.
Otherwise, search for `wx-config' in the PATH directories and return the
first match found. Failing that, return None.
"""

wxconfig = os.getenv('WX_CONFIG')
if wxconfig is not None:
return wxconfig

path = os.getenv('PATH') or ''
for dir in path.split(':'):
wxconfig = os.path.join(dir, 'wx-config')
if os.path.exists(wxconfig):
return wxconfig

return None

def check_wxpython_broken_macosx104_version(wxconfig):
"""Determines if we're using a broken wxPython installed by Mac OS X 10.4"""
if sys.platform == 'darwin':
if wxconfig == '/usr/bin/wx-config':
version_full = getoutput(wxconfig + ' --version-full')
if version_full == '2.5.3.1':
return False
return True

def add_wx_flags(module, wxconfig):
"""
Add the module flags to build extensions which use wxPython.
"""

if sys.platform == 'win32': # just added manually
wxlibs = ['wxexpath', 'wxjpegh', 'wxmsw26uh',
'wxmsw26uh_animate', 'wxmsw26uh_gizmos', 'wxmsw26uh_gizmos_xrc',
'wxmsw26uh_gl', 'wxmsw26uh_stc', 'wxpngh', 'wxregexuh', 'wxtiffh', 'wxzlibh']
module.libraries.extend(wxlibs)
module.libraries.extend(wxlibs)
return

get_pkgconfig(module, '', flags='--cppflags --libs', pkg_config_exec='wx-config')

# Make sure you use the Tk version given by Tkinter.TkVersion
# or else you'll build for a wrong version of the Tcl
# interpreter (leading to nasty segfaults).
Expand Down Expand Up @@ -1200,25 +1104,6 @@ def build_tkagg(ext_modules, packages):
BUILT_TKAGG = True


def build_wxagg(ext_modules, packages):
global BUILT_WXAGG
if BUILT_WXAGG:
return

deps = ['src/_wxagg.cpp', 'src/mplutils.cpp']
deps.extend(glob.glob('CXX/*.cxx'))
deps.extend(glob.glob('CXX/*.c'))

module = Extension('matplotlib.backends._wxagg', deps)

add_agg_flags(module)
add_ft2font_flags(module)
wxconfig = find_wx_config()
add_wx_flags(module, wxconfig)

ext_modules.append(module)
BUILT_WXAGG = True

def build_macosx(ext_modules, packages):
global BUILT_MACOSX
if BUILT_MACOSX: return # only build it if you you haven't already
Expand Down
Loading

0 comments on commit 89435dd

Please sign in to comment.