Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit35c1bfd

Browse files
committed
Avoid "dash motion" in qt zoom box.
Drawing the whole zoom box as a single rectangle causes the dashes onthe "last" edge of the rectangle to keep shifting (basically dependingon the total length of the other three edges). Instead, draw the zoombox as 4 separate lines always going from the "fixed" point (x0, y0)towards to "mobile" point (x1, y1) so to avoid this effect.
1 parent015ff47 commit35c1bfd

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

‎lib/matplotlib/backends/backend_qt5.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,16 +478,23 @@ def drawRectangle(self, rect):
478478
# Draw the zoom rectangle to the QPainter. _draw_rect_callback needs
479479
# to be called at the end of paintEvent.
480480
ifrectisnotNone:
481+
x0,y0,w,h= [pt/self._dpi_ratioforptinrect]
482+
x1=x0+w
483+
y1=y0+h
481484
def_draw_rect_callback(painter):
482-
scaled_rect= [pt/self._dpi_ratioforptinrect]
483485
pen=QtGui.QPen(QtCore.Qt.black,1/self._dpi_ratio)
484486
pen.setDashPattern([3,3])
485-
painter.setPen(pen)
486-
painter.drawRect(*scaled_rect)
487-
pen.setDashOffset(3)
488-
pen.setColor(QtCore.Qt.white)
489-
painter.setPen(pen)
490-
painter.drawRect(*scaled_rect)
487+
forcolor,offsetin [
488+
(QtCore.Qt.black,0), (QtCore.Qt.white,3)]:
489+
pen.setDashOffset(offset)
490+
pen.setColor(color)
491+
painter.setPen(pen)
492+
# Draw the lines from x0, y0 towards x1, y1 so that the
493+
# dashes don't "jump" when moving the zoom box.
494+
painter.drawLine(x0,y0,x0,y1)
495+
painter.drawLine(x0,y0,x1,y0)
496+
painter.drawLine(x0,y1,x1,y1)
497+
painter.drawLine(x1,y0,x1,y1)
491498
else:
492499
def_draw_rect_callback(painter):
493500
return

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp