Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benjamin Jakimow
EO Time Series Viewer
Commits
35357308
Commit
35357308
authored
May 29, 2012
by
Luke Campagnola
Browse files
ArrowItem has more flexibility in the shapes it can draw
parent
f258c3d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
graphicsItems/ArrowItem.py
View file @
35357308
from
pyqtgraph.Qt
import
QtGui
,
QtCore
import
pyqtgraph.functions
as
fn
import
numpy
as
np
__all__
=
[
'ArrowItem'
]
class
ArrowItem
(
QtGui
.
QGraphicsPolygonItem
):
class
ArrowItem
(
QtGui
.
QGraphicsPathItem
):
"""
For displaying scale-invariant arrows.
For arrows pointing to a location on a curve, see CurveArrow
...
...
@@ -11,16 +12,16 @@ class ArrowItem(QtGui.QGraphicsPolygonItem):
def
__init__
(
self
,
**
opts
):
QtGui
.
QGraphicsP
olygon
Item
.
__init__
(
self
,
opts
.
get
(
'parent'
,
None
))
QtGui
.
QGraphicsP
ath
Item
.
__init__
(
self
,
opts
.
get
(
'parent'
,
None
))
defOpts
=
{
'style'
:
'tri'
,
'pxMode'
:
True
,
'size'
:
20
,
'angle'
:
-
150
,
## If the angle is 0, the arrow points left
'pos'
:
(
0
,
0
),
'
width'
:
None
,
## width is automatically size / 2.
'
headLen'
:
20
,
'tipAngle'
:
25
,
'baseAngle'
:
90
,
'baseAngle'
:
0
,
'tailLen'
:
None
,
'tailWidth'
:
3
,
'pen'
:
(
200
,
200
,
200
),
'brush'
:
(
50
,
50
,
200
),
}
...
...
@@ -37,23 +38,9 @@ class ArrowItem(QtGui.QGraphicsPolygonItem):
def
setStyle
(
self
,
**
opts
):
self
.
opts
=
opts
if
opts
[
'style'
]
==
'tri'
:
if
opts
[
'width'
]
is
None
:
width
=
opts
[
'size'
]
/
2.
else
:
width
=
opts
[
'width'
]
points
=
[
QtCore
.
QPointF
(
0
,
0
),
QtCore
.
QPointF
(
opts
[
'size'
],
-
width
/
2.
),
QtCore
.
QPointF
(
opts
[
'size'
],
width
/
2.
),
]
poly
=
QtGui
.
QPolygonF
(
points
)
else
:
raise
Exception
(
"Unrecognized arrow style '%s'"
%
opts
[
'style'
])
self
.
setPolygon
(
poly
)
opt
=
{
k
:
self
.
opts
[
k
]
for
k
in
[
'headLen'
,
'tipAngle'
,
'baseAngle'
,
'tailLen'
,
'tailWidth'
]}
self
.
path
=
fn
.
makeArrowPath
(
**
opt
)
self
.
setPath
(
self
.
path
)
if
opts
[
'pxMode'
]:
self
.
setFlags
(
self
.
flags
()
|
self
.
ItemIgnoresTransformations
)
...
...
@@ -62,4 +49,4 @@ class ArrowItem(QtGui.QGraphicsPolygonItem):
def
paint
(
self
,
p
,
*
args
):
p
.
setRenderHint
(
QtGui
.
QPainter
.
Antialiasing
)
QtGui
.
QGraphicsP
olygon
Item
.
paint
(
self
,
p
,
*
args
)
QtGui
.
QGraphicsP
ath
Item
.
paint
(
self
,
p
,
*
args
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment