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
bdb6ff88
Commit
bdb6ff88
authored
Apr 04, 2012
by
Luke Campagnola
Browse files
Updates to IsocurveItem, added isocurve example
minor updates for other examples
parent
fffbd554
Changes
5
Hide whitespace changes
Inline
Side-by-side
examples/Arrow.py
View file @
bdb6ff88
...
...
@@ -7,8 +7,6 @@
## To place a static arrow anywhere in a scene, use ArrowItem.
## To attach other types of item to a curve, use CurvePoint.
## Add path to library (just for examples; you do not need this)
import
initExample
## Add path to library (just for examples; you do not need this)
import
numpy
as
np
...
...
examples/VideoSpeedTest.py
View file @
bdb6ff88
#!/usr/bin/python
# -*- coding: utf-8 -*-
## Add path to library (just for examples; you do not need this)
import
sys
,
os
,
time
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
))
"""
Tests the speed of image updates for an ImageItem and RawImageWidget.
The speed will generally depend on the type of data being shown, whether
it is being scaled and/or converted by lookup table, and whether OpenGL
is used by the view widget
"""
import
initExample
## Add path to library (just for examples; you do not need this)
from
pyqtgraph.Qt
import
QtGui
,
QtCore
...
...
@@ -136,6 +141,7 @@ timer.start(0)
## Start Qt event loop unless running in interactive mode.
if
sys
.
flags
.
interactive
!=
1
:
## Start Qt event loop unless running in interactive mode or using pyside.
import
sys
if
(
sys
.
flags
.
interactive
!=
1
)
or
not
hasattr
(
QtCore
,
'PYQT_VERSION'
):
app
.
exec_
()
examples/__main__.py
View file @
bdb6ff88
...
...
@@ -12,9 +12,13 @@ examples = OrderedDict([
(
'Basic Plotting'
,
'Plotting.py'
),
(
'ImageView'
,
'ImageView.py'
),
(
'ParameterTree'
,
'../parametertree'
),
(
'Crosshair / Mouse interaction'
,
'crosshair.py'
),
(
'Video speed test'
,
'VideoSpeedTest.py'
),
(
'Plot speed test'
,
'PlotSpeedTest.py'
),
(
'GraphicsItems'
,
OrderedDict
([
(
'Scatter Plot'
,
'ScatterPlot.py'
),
#('PlotItem', 'PlotItem.py'),
(
'IsocurveItem'
,
'isocurve.py'
),
(
'ImageItem - video'
,
'ImageItem.py'
),
(
'ImageItem - draw'
,
'Draw.py'
),
(
'Region-of-Interest'
,
'ROItypes.py'
),
...
...
@@ -90,7 +94,10 @@ class ExampleLoader(QtGui.QMainWindow):
fn
=
self
.
currentFile
()
if
fn
is
None
:
return
os
.
spawnl
(
os
.
P_NOWAIT
,
sys
.
executable
,
sys
.
executable
,
'"'
+
fn
+
'"'
)
if
sys
.
platform
.
startswith
(
'win'
):
os
.
spawnl
(
os
.
P_NOWAIT
,
sys
.
executable
,
sys
.
executable
,
'"'
+
fn
+
'"'
)
else
:
os
.
spawnl
(
os
.
P_NOWAIT
,
sys
.
executable
,
sys
.
executable
,
fn
)
def
showFile
(
self
):
...
...
examples/isocurve.py
0 → 100644
View file @
bdb6ff88
# -*- coding: utf-8 -*-
"""
Tests use of IsoCurve item displayed with image
"""
import
initExample
## Add path to library (just for examples; you do not need this)
from
pyqtgraph.Qt
import
QtGui
,
QtCore
import
numpy
as
np
import
pyqtgraph
as
pg
import
scipy.ndimage
as
ndi
app
=
QtGui
.
QApplication
([])
## make pretty looping data
frames
=
200
data
=
np
.
random
.
normal
(
size
=
(
frames
,
30
,
30
),
loc
=
0
,
scale
=
100
)
data
=
np
.
concatenate
([
data
,
data
],
axis
=
0
)
data
=
ndi
.
gaussian_filter
(
data
,
(
10
,
10
,
10
))[
frames
/
2
:
frames
+
frames
/
2
]
win
=
pg
.
GraphicsWindow
()
vb
=
win
.
addViewBox
()
img
=
pg
.
ImageItem
(
data
[
0
])
vb
.
addItem
(
img
)
vb
.
setAspectLocked
()
## generate empty curves
curves
=
[]
levels
=
np
.
linspace
(
data
.
min
(),
data
.
max
(),
10
)
for
i
in
range
(
len
(
levels
)):
v
=
levels
[
i
]
## generate isocurve with automatic color selection
c
=
pg
.
IsocurveItem
(
level
=
v
,
pen
=
(
i
,
len
(
levels
)
*
1.5
))
c
.
setParentItem
(
img
)
## make sure isocurve is always correctly displayed over image
c
.
setZValue
(
10
)
curves
.
append
(
c
)
## animate!
ptr
=
0
imgLevels
=
(
data
.
min
(),
data
.
max
()
*
2
)
def
update
():
global
data
,
curves
,
img
,
ptr
,
imgLevels
ptr
=
(
ptr
+
1
)
%
data
.
shape
[
0
]
data
[
ptr
]
img
.
setImage
(
data
[
ptr
],
levels
=
imgLevels
)
for
c
in
curves
:
c
.
setData
(
data
[
ptr
])
timer
=
QtCore
.
QTimer
()
timer
.
timeout
.
connect
(
update
)
timer
.
start
(
50
)
## Start Qt event loop unless running in interactive mode or using pyside.
import
sys
if
(
sys
.
flags
.
interactive
!=
1
)
or
not
hasattr
(
QtCore
,
'PYQT_VERSION'
):
app
.
exec_
()
graphicsItems/IsocurveItem.py
View file @
bdb6ff88
...
...
@@ -2,7 +2,7 @@
from
GraphicsObject
import
*
import
pyqtgraph.functions
as
fn
from
pyqtgraph.Qt
import
QtGui
from
pyqtgraph.Qt
import
QtGui
,
QtCore
class
IsocurveItem
(
GraphicsObject
):
...
...
@@ -13,26 +13,50 @@ class IsocurveItem(GraphicsObject):
call isocurve.setParentItem(image)
"""
def
__init__
(
self
,
data
,
level
,
pen
=
'w'
):
def
__init__
(
self
,
data
=
None
,
level
=
0
,
pen
=
'w'
):
GraphicsObject
.
__init__
(
self
)
lines
=
fn
.
isocurve
(
data
,
level
)
self
.
path
=
QtGui
.
QPainterPath
(
)
self
.
level
=
0
self
.
data
=
None
self
.
path
=
None
self
.
setData
(
data
,
level
)
self
.
setPen
(
pen
)
for
line
in
lines
:
self
.
path
.
moveTo
(
*
line
[
0
])
self
.
path
.
lineTo
(
*
line
[
1
])
def
setData
(
self
,
data
,
level
=
None
):
if
level
is
None
:
level
=
self
.
level
self
.
level
=
level
self
.
data
=
data
self
.
path
=
None
self
.
prepareGeometryChange
()
self
.
update
()
def
setLevel
(
self
,
level
):
self
.
level
=
level
self
.
path
=
None
self
.
update
()
def
setPen
(
self
,
*
args
,
**
kwargs
):
self
.
pen
=
fn
.
mkPen
(
*
args
,
**
kwargs
)
self
.
update
()
def
boundingRect
(
self
):
if
self
.
path
is
None
:
return
QtCore
.
QRectF
()
return
self
.
path
.
boundingRect
()
def
generatePath
(
self
):
self
.
path
=
QtGui
.
QPainterPath
()
if
self
.
data
is
None
:
return
lines
=
fn
.
isocurve
(
self
.
data
,
self
.
level
)
for
line
in
lines
:
self
.
path
.
moveTo
(
*
line
[
0
])
self
.
path
.
lineTo
(
*
line
[
1
])
def
paint
(
self
,
p
,
*
args
):
if
self
.
path
is
None
:
self
.
generatePath
()
p
.
setPen
(
self
.
pen
)
p
.
drawPath
(
self
.
path
)
\ No newline at end of file
Write
Preview
Markdown
is supported
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