From 1d4b89a909a0e6234862942fa754452116254475 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Wobst?= Date: Mon, 10 Oct 2011 21:17:23 +0000 Subject: [PATCH] default bbox method of canvasitem is weird; for the moment just document the issue git-svn-id: https://pyx.svn.sourceforge.net/svnroot/pyx/trunk/pyx@3224 069f4177-920e-0410-937b-c2a4a81bcd90 --- pyx/canvasitem.py | 5 +++++ pyx/dvi/dvifile.py | 16 ++++++++++++---- pyx/style.py | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/pyx/canvasitem.py b/pyx/canvasitem.py index fce9d69f..726bb9dc 100644 --- a/pyx/canvasitem.py +++ b/pyx/canvasitem.py @@ -26,6 +26,11 @@ class canvasitem: def bbox(self): """return bounding box of canvasitem""" + # TODO: we either should raise a NotImplementedError here or return + # an empty bounding box instance, as adding empty to a bouding box is + # allowed. (We could also alter the merging behavior of bboxes to allow + # None. Currently, canvasitem instances not overwriting this bbox method + # lead to an error.) pass def processPS(self, file, writer, context, registry, bbox): diff --git a/pyx/dvi/dvifile.py b/pyx/dvi/dvifile.py index b1e81237..010b0e4a 100644 --- a/pyx/dvi/dvifile.py +++ b/pyx/dvi/dvifile.py @@ -79,7 +79,14 @@ class DVIError(Exception): pass # save and restore colors -class _savecolor(canvasitem.canvasitem): +class _canvasitem(canvasitem.canvasitem): + + def bbox(self): + # TODO: see TODO in bbox method of canvasitem + return bbox.empty() + + +class _savecolor(_canvasitem): def processPS(self, file, writer, context, registry, bbox): file.write("currentcolor currentcolorspace\n") @@ -87,14 +94,15 @@ class _savecolor(canvasitem.canvasitem): file.write("q\n") -class _restorecolor(canvasitem.canvasitem): +class _restorecolor(_canvasitem): def processPS(self, file, writer, context, registry, bbox): file.write("setcolorspace setcolor\n") def processPDF(self, file, writer, context, registry, bbox): file.write("Q\n") -class _savetrafo(canvasitem.canvasitem): + +class _savetrafo(_canvasitem): def processPS(self, file, writer, context, registry, bbox): file.write("matrix currentmatrix\n") @@ -102,7 +110,7 @@ class _savetrafo(canvasitem.canvasitem): file.write("q\n") -class _restoretrafo(canvasitem.canvasitem): +class _restoretrafo(_canvasitem): def processPS(self, file, writer, context, registry, bbox): file.write("setmatrix\n") diff --git a/pyx/style.py b/pyx/style.py index b862c464..39883c82 100644 --- a/pyx/style.py +++ b/pyx/style.py @@ -31,10 +31,12 @@ import bbox as bboxmodule class strokestyle(canvasitem.canvasitem): def bbox(self): + # TODO: see TODO in bbox method of canvasitem return bboxmodule.empty() class fillstyle(canvasitem.canvasitem): def bbox(self): + # TODO: see TODO in bbox method of canvasitem return bboxmodule.empty() # -- 2.11.4.GIT