Skip to content

Commit

Permalink
g.gui.iclass: replace dist_point_to_segment()
Browse files Browse the repository at this point in the history
from matplotlib, which was disabled for matplotlib 3.1.0+.

Fixes: #461
  • Loading branch information
nilason committed May 18, 2020
1 parent 71c8a1f commit 892183b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gui/wxpython/iscatt/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
FigureCanvasWxAgg as FigCanvas
from matplotlib.lines import Line2D
from matplotlib.artist import Artist
from matplotlib.mlab import dist_point_to_segment
from matplotlib.patches import Polygon, Ellipse, Rectangle
import matplotlib.image as mi
import matplotlib.colors as mcolors
Expand Down Expand Up @@ -838,6 +837,13 @@ def _deleteVertex(self, event):

self.Redraw()

def _dist_point_to_segment(p, s0, s1):
p = np.asarray(p, float)
s0 = np.asarray(s0, float)
s1 = np.asarray(s1, float)

return np.cross(s1-s0, p-s0)/np.linalg.norm(s1-s0)

def _addVertexOnBoundary(self, event):
if self.empty_pol:
return
Expand All @@ -847,7 +853,7 @@ def _addVertexOnBoundary(self, event):
for i in range(len(xys) - 1):
s0 = xys[i]
s1 = xys[i + 1]
d = dist_point_to_segment(p, s0, s1)
d = self._dist_point_to_segment(p, s0, s1)

if d <= self._getSnapTresh():
self.pol.xy = np.array(
Expand Down

0 comments on commit 892183b

Please sign in to comment.