Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6a18d6b

Browse filesBrowse files
tacaswellMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR #9396: Fix minor bug in vertex insert
1 parent 4ba4766 commit 6a18d6b
Copy full SHA for 6a18d6b

File tree

Expand file treeCollapse file tree

1 file changed

+10
-10
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-10
lines changed

‎examples/event_handling/poly_editor.py

Copy file name to clipboardExpand all lines: examples/event_handling/poly_editor.py
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ def draw_callback(self, event):
5959
self.background = self.canvas.copy_from_bbox(self.ax.bbox)
6060
self.ax.draw_artist(self.poly)
6161
self.ax.draw_artist(self.line)
62-
self.canvas.blit(self.ax.bbox)
62+
# do not need to blit here, this will fire before the screen is
63+
# updated
6364

6465
def poly_changed(self, poly):
6566
'this method is called whenever the polygon object is called'
@@ -114,9 +115,8 @@ def key_press_callback(self, event):
114115
elif event.key == 'd':
115116
ind = self.get_ind_under_point(event)
116117
if ind is not None:
117-
self.poly.xy = [tup
118-
for i, tup in enumerate(self.poly.xy)
119-
if i != ind]
118+
self.poly.xy = np.delete(self.poly.xy,
119+
ind, axis=0)
120120
self.line.set_data(zip(*self.poly.xy))
121121
elif event.key == 'i':
122122
xys = self.poly.get_transform().transform(self.poly.xy)
@@ -126,14 +126,14 @@ def key_press_callback(self, event):
126126
s1 = xys[i + 1]
127127
d = dist_point_to_segment(p, s0, s1)
128128
if d <= self.epsilon:
129-
self.poly.xy = np.array(
130-
list(self.poly.xy[:i]) +
131-
[(event.xdata, event.ydata)] +
132-
list(self.poly.xy[i:]))
129+
self.poly.xy = np.insert(
130+
self.poly.xy, i+1,
131+
[event.xdata, event.ydata],
132+
axis=0)
133133
self.line.set_data(zip(*self.poly.xy))
134134
break
135-
136-
self.canvas.draw()
135+
if self.line.stale:
136+
self.canvas.draw_idle()
137137

138138
def motion_notify_callback(self, event):
139139
'on mouse movement'

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.