Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 91f3ab0

Browse files
committed
Merged revisions 5012-5017,5019-5023 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r5013 | mmetz_bn | 2008-03-21 13:19:37 -0400 (Fri, 21 Mar 2008) | 1 line Bugfix in ContourSet._process_linestyles ........ r5021 | mdboom | 2008-03-26 10:30:18 -0400 (Wed, 26 Mar 2008) | 3 lines Change character ids so they are a hash on the path data itself. (To fix Kaushik Ghose's copy-and-paste in Inkscape bug). ........ r5022 | mdboom | 2008-03-26 10:33:35 -0400 (Wed, 26 Mar 2008) | 3 lines Change character ids so they are a hash on the path data itself. (To fix Kaushik Ghose's copy-and-paste in Inkscape bug). ........ r5023 | mdboom | 2008-03-26 10:35:50 -0400 (Wed, 26 Mar 2008) | 2 lines Oops in last commit. ........ svn path=/trunk/matplotlib/; revision=5024
1 parent 5364cf9 commit 91f3ab0

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2008-03-26 Fix SVG backend bug that prevents copying and pasting in
2+
Inkscape (thanks Kaushik Ghose) - MGD
3+
14
2008-03-24 Removed an unnecessary call to draw() in the backend_qt*
25
mouseReleaseEvent. Thanks to Ted Drain - DSD
36

lib/matplotlib/backends/backend_svg.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import division
22

3-
import os, codecs, base64, tempfile, urllib, gzip
3+
import os, codecs, base64, tempfile, urllib, gzip, md5
44

55
from matplotlib import verbose, __version__, rcParams
66
from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\
@@ -125,7 +125,7 @@ def _get_gc_clip_svg(self, gc):
125125

126126
id = self._clipd.get(path)
127127
if id is None:
128-
id = 'p%x' % len(self._clipd)
128+
id = 'p%s' % md5.new(path).hexdigest()
129129
self._svgwriter.write('<defs>\n <clipPath id="%s">\n' % id)
130130
self._svgwriter.write(path)
131131
self._svgwriter.write('\n </clipPath>\n</defs>')
@@ -189,7 +189,7 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None)
189189
key = self._convert_path(marker_path, marker_trans + Affine2D().scale(1.0, -1.0))
190190
name = self._markers.get(key)
191191
if name is None:
192-
name = 'm%x' % len(self._markers)
192+
name = 'm%s' % md5.new(key).hexdigest()
193193
write('<defs><path id="%s" d="%s"/></defs>\n' % (name, key))
194194
self._markers[key] = name
195195

@@ -209,9 +209,10 @@ def draw_path_collection(self, master_transform, cliprect, clippath,
209209
write('<defs>\n')
210210
for i, (path, transform) in enumerate(self._iter_collection_raw_paths(
211211
master_transform, paths, all_transforms)):
212-
name = 'coll%x_%x' % (self._path_collection_id, i)
213212
transform = Affine2D(transform.get_matrix()).scale(1.0, -1.0)
214213
d = self._convert_path(path, transform)
214+
name = 'coll%x_%x_%s' % (self._path_collection_id, i,
215+
md5.new(d).hexdigest())
215216
write('<path id="%s" d="%s"/>\n' % (name, d))
216217
path_codes.append(name)
217218
write('</defs>\n')
@@ -398,8 +399,9 @@ def _add_char_def(self, prop, char):
398399

399400
if step[0] != 4:
400401
currx, curry = step[-2], -step[-1]
401-
char_num = 'c%x' % len(self._char_defs)
402-
path_element = '<path id="%s" d="%s"/>\n' % (char_num, ''.join(path_data))
402+
path_data = ''.join(path_data)
403+
char_num = 'c_%s' % md5.new(path_data).hexdigest()
404+
path_element = '<symbol id="%s"><path d="%s"/></symbol>\n' % (char_num, ''.join(path_data))
403405
self._char_defs[char_id] = char_num
404406
return path_element
405407

0 commit comments

Comments
 (0)