|
From: <ef...@us...> - 2009-08-10 00:20:04
|
Revision: 7443
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7443&view=rev
Author: efiring
Date: 2009-08-10 00:19:19 +0000 (Mon, 10 Aug 2009)
Log Message:
-----------
Patch from Jason, sage project: prevent failure with tiny arrows.
Also deleting unwanted whitespace in bezier.py.
Modified Paths:
--------------
branches/v0_99_maint/lib/matplotlib/bezier.py
branches/v0_99_maint/lib/matplotlib/patches.py
Modified: branches/v0_99_maint/lib/matplotlib/bezier.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/bezier.py 2009-08-10 00:02:56 UTC (rev 7442)
+++ branches/v0_99_maint/lib/matplotlib/bezier.py 2009-08-10 00:19:19 UTC (rev 7443)
@@ -18,7 +18,7 @@
""" return a intersecting point between a line through (cx1, cy1)
and having angle t1 and a line through (cx2, cy2) and angle t2.
"""
-
+
# line1 => sin_t1 * (x - cx1) - cos_t1 * (y - cy1) = 0.
# line1 => sin_t1 * x + cos_t1 * y = sin_t1*cx1 - cos_t1*cy1
@@ -32,7 +32,7 @@
ad_bc = a*d-b*c
if ad_bc == 0.:
raise ValueError("Given lines do not intersect")
-
+
#rhs_inverse
a_, b_ = d, -b
c_, d_ = -c, a
@@ -53,7 +53,7 @@
if length == 0.:
return cx, cy, cx, cy
-
+
cos_t1, sin_t1 = sin_t, -cos_t
cos_t2, sin_t2 = -sin_t, cos_t
@@ -81,7 +81,7 @@
def split_de_casteljau(beta, t):
"""split a bezier segment defined by its controlpoints *beta*
into two separate segment divided at *t* and return their control points.
-
+
"""
beta = np.asarray(beta)
beta_list = [beta]
@@ -101,20 +101,20 @@
-def find_bezier_t_intersecting_with_closedpath(bezier_point_at_t, inside_closedpath,
+def find_bezier_t_intersecting_with_closedpath(bezier_point_at_t, inside_closedpath,
t0=0., t1=1., tolerence=0.01):
""" Find a parameter t0 and t1 of the given bezier path which
bounds the intersecting points with a provided closed
path(*inside_closedpath*). Search starts from *t0* and *t1* and it
uses a simple bisecting algorithm therefore one of the end point
must be inside the path while the orther doesn't. The search stop
- when |t0-t1| gets smaller than the given tolerence.
+ when |t0-t1| gets smaller than the given tolerence.
value for
- bezier_point_at_t : a function which returns x, y coordinates at *t*
- inside_closedpath : return True if the point is insed the path
-
+
"""
# inside_closedpath : function
@@ -146,11 +146,11 @@
t0 = middle_t
start = middle
start_inside = middle_inside
-
+
class BezierSegment:
"""
A simple class of a 2-dimensional bezier segment
@@ -192,19 +192,19 @@
def split_bezier_intersecting_with_closedpath(bezier,
- inside_closedpath,
+ inside_closedpath,
tolerence=0.01):
"""
bezier : control points of the bezier segment
inside_closedpath : a function which returns true if the point is inside the path
"""
-
+
bz = BezierSegment(bezier)
bezier_point_at_t = bz.point_at_t
t0, t1 = find_bezier_t_intersecting_with_closedpath(bezier_point_at_t,
- inside_closedpath,
+ inside_closedpath,
tolerence=tolerence)
_left, _right = split_de_casteljau(bezier, (t0+t1)/2.)
@@ -213,23 +213,23 @@
def find_r_to_boundary_of_closedpath(inside_closedpath, xy,
- cos_t, sin_t,
+ cos_t, sin_t,
rmin=0., rmax=1., tolerence=0.01):
"""
Find a radius r (centered at *xy*) between *rmin* and *rmax* at
which it intersect with the path.
-
+
inside_closedpath : function
cx, cy : center
cos_t, sin_t : cosine and sine for the angle
- rmin, rmax :
+ rmin, rmax :
"""
cx, cy = xy
def _f(r):
return cos_t*r + cx, sin_t*r + cy
- find_bezier_t_intersecting_with_closedpath(_f, inside_closedpath,
+ find_bezier_t_intersecting_with_closedpath(_f, inside_closedpath,
t0=rmin, t1=rmax, tolerence=tolerence)
@@ -238,7 +238,7 @@
def split_path_inout(path, inside, tolerence=0.01, reorder_inout=False):
""" divide a path into two segment at the point where inside(x, y)
- becomes False.
+ becomes False.
"""
path_iter = path.iter_segments()
@@ -262,7 +262,7 @@
break
ctl_points_old = ctl_points
-
+
if bezier_path is None:
raise ValueError("The path does not seem to intersect with the patch")
@@ -286,7 +286,7 @@
verts_right = right[:]
#i += 1
-
+
if path.codes is None:
path_in = Path(concat([path.vertices[:i], verts_left]))
path_out = Path(concat([verts_right, path.vertices[i:]]))
@@ -297,16 +297,16 @@
path_out = Path(concat([verts_right, path.vertices[i:]]),
concat([codes_right, path.codes[i:]]))
-
+
if reorder_inout and begin_inside == False:
path_in, path_out = path_out, path_in
return path_in, path_out
-
-
+
+
def inside_circle(cx, cy, r):
r2 = r**2
def _f(xy):
@@ -328,7 +328,7 @@
"""
Given the quadraitc bezier control points *bezier2*, returns
control points of quadrativ bezier lines roughly parralel to given
- one separated by *width*.
+ one separated by *width*.
"""
# The parallel bezier lines constructed by following ways.
@@ -374,7 +374,7 @@
"""
Being similar to get_parallels, returns
control points of two quadrativ bezier lines having a width roughly parralel to given
- one separated by *width*.
+ one separated by *width*.
"""
xx1, yy1 = bezier2[2]
@@ -389,17 +389,17 @@
x1, y1, x2, y2 = get_normal_points(cx, cy, cos_t, sin_t, length)
- xx12, yy12 = (xx1+xx2)/2., (yy1+yy2)/2.,
- xx23, yy23 = (xx2+xx3)/2., (yy2+yy3)/2.,
+ xx12, yy12 = (xx1+xx2)/2., (yy1+yy2)/2.,
+ xx23, yy23 = (xx2+xx3)/2., (yy2+yy3)/2.,
dist = sqrt((xx12-xx23)**2 + (yy12-yy23)**2)
cos_t, sin_t = (xx12-xx23)/dist, (yy12-yy23)/dist,
-
+
xm1, ym1, xm2, ym2 = get_normal_points(xx2, yy2, cos_t, sin_t, length*shrink_factor)
l_plus = [(x1, y1), (xm1, ym1), (xx1, yy1)]
l_minus = [(x2, y2), (xm2, ym2), (xx1, yy1)]
-
+
return l_plus, l_minus
@@ -418,7 +418,7 @@
"""
Being similar to get_parallels, returns
control points of two quadrativ bezier lines having a width roughly parralel to given
- one separated by *width*.
+ one separated by *width*.
"""
# c1, cm, c2
@@ -446,9 +446,9 @@
# find c12, c23 and c123 which are middle points of c1-cm, cm-c3 and c12-c23
c12x, c12y = (c1x+cmx)*.5, (c1y+cmy)*.5
- c23x, c23y = (cmx+c3x)*.5, (cmy+c3y)*.5
+ c23x, c23y = (cmx+c3x)*.5, (cmy+c3y)*.5
c123x, c123y = (c12x+c23x)*.5, (c12y+c23y)*.5
-
+
# tangential angle of c123 (angle between c12 and c23)
cos_t123, sin_t123 = get_cos_sin(c12x, c12y, c23x, c23y)
@@ -481,7 +481,7 @@
return Path(p.vertices, c)
else:
return p
-
+
def concatenate_paths(paths):
"""
concatenate list of paths into a single path.
Modified: branches/v0_99_maint/lib/matplotlib/patches.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/patches.py 2009-08-10 00:02:56 UTC (rev 7442)
+++ branches/v0_99_maint/lib/matplotlib/patches.py 2009-08-10 00:19:19 UTC (rev 7443)
@@ -2326,15 +2326,21 @@
x, y = path.vertices[0]
insideA = inside_circle(x, y, shrinkA)
- left, right = split_path_inout(path, insideA)
- path = right
+ try:
+ left, right = split_path_inout(path, insideA)
+ path = right
+ except ValueError:
+ pass
if shrinkB:
x, y = path.vertices[-1]
insideB = inside_circle(x, y, shrinkB)
- left, right = split_path_inout(path, insideB)
- path = left
+ try:
+ left, right = split_path_inout(path, insideB)
+ path = left
+ except ValueError:
+ pass
return path
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-08-30 13:35:26
|
Revision: 7598
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7598&view=rev
Author: jdh2358
Date: 2009-08-30 13:35:12 +0000 (Sun, 30 Aug 2009)
Log Message:
-----------
applied Gael's ginput patch
Modified Paths:
--------------
branches/v0_99_maint/lib/matplotlib/blocking_input.py
branches/v0_99_maint/lib/matplotlib/figure.py
Modified: branches/v0_99_maint/lib/matplotlib/blocking_input.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/blocking_input.py 2009-08-30 10:33:01 UTC (rev 7597)
+++ branches/v0_99_maint/lib/matplotlib/blocking_input.py 2009-08-30 13:35:12 UTC (rev 7598)
@@ -17,9 +17,6 @@
Note: Subclass of BlockingMouseInput. Used by clabel
"""
-import time
-import numpy as np
-
from matplotlib import path, verbose
from matplotlib.cbook import is_sequence_of_strings
@@ -151,7 +148,7 @@
button = event.button
if button == self.button_pop:
- self.mouse_event_pop(event,-1)
+ self.mouse_event_pop(event)
elif button == self.button_stop:
self.mouse_event_stop(event)
else:
@@ -162,7 +159,7 @@
Process a key click event. This maps certain keys to appropriate
mouse click events.
'''
-
+
event = self.events[-1]
key = event.key.lower()
Modified: branches/v0_99_maint/lib/matplotlib/figure.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/figure.py 2009-08-30 10:33:01 UTC (rev 7597)
+++ branches/v0_99_maint/lib/matplotlib/figure.py 2009-08-30 13:35:12 UTC (rev 7598)
@@ -12,7 +12,6 @@
"""
import numpy as np
-import time
import artist
from artist import Artist, allow_rasterization
@@ -1105,6 +1104,12 @@
Right clicking cancels last input.
+ The buttons used for the various actions (adding points, removing
+ points, terminating the inputs) can be overriden via the
+ arguments *mouse_add*, *mouse_pop* and *mouse_stop*, that give
+ the associated mouse button: 1 for left, 2 for middle, 3 for
+ right.
+
The keyboard can also be used to select points in case your mouse
does not have one or more of the buttons. The delete and backspace
keys act like right clicking (i.e., remove last point), the enter key
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2009-11-06 19:25:07
|
Revision: 7944
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7944&view=rev
Author: mdboom
Date: 2009-11-06 19:24:55 +0000 (Fri, 06 Nov 2009)
Log Message:
-----------
Add support for \widebar{} in mathtext (Thanks Sean Arms)
Modified Paths:
--------------
branches/v0_99_maint/lib/matplotlib/_mathtext_data.py
branches/v0_99_maint/lib/matplotlib/mathtext.py
Modified: branches/v0_99_maint/lib/matplotlib/_mathtext_data.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/_mathtext_data.py 2009-11-06 15:06:28 UTC (rev 7943)
+++ branches/v0_99_maint/lib/matplotlib/_mathtext_data.py 2009-11-06 19:24:55 UTC (rev 7944)
@@ -41,6 +41,7 @@
r'\rangle' : ('cmex10', 64),
r'\widehat' : ('cmex10', 15),
r'\widetilde' : ('cmex10', 52),
+ r'\widebar' : ('cmr10', 131),
r'\omega' : ('cmmi10', 29),
r'\varepsilon' : ('cmmi10', 20),
@@ -1762,6 +1763,7 @@
tex2uni = {
'widehat': 0x0302,
'widetilde': 0x0303,
+'widebar': 0x0305,
'langle': 0x27e8,
'rangle': 0x27e9,
'perp': 0x27c2,
Modified: branches/v0_99_maint/lib/matplotlib/mathtext.py
===================================================================
--- branches/v0_99_maint/lib/matplotlib/mathtext.py 2009-11-06 15:06:28 UTC (rev 7943)
+++ branches/v0_99_maint/lib/matplotlib/mathtext.py 2009-11-06 19:24:55 UTC (rev 7944)
@@ -2450,7 +2450,7 @@
r'overleftarrow' : r'\leftarrow'
}
- _wide_accents = set(r"widehat widetilde".split())
+ _wide_accents = set(r"widehat widetilde widebar".split())
def accent(self, s, loc, toks):
assert(len(toks)==1)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|