Avoid constructing shadow pens when no shadow pen is set
Basically, profiling has pointed me to the fact that a fair bit of code time is spent in `setShadowPen()` (actually, it's in `mkPen()`, which `setShadowPen()` calls), even when no shadow pen is specified. In my application, I'm calling `pyqtgraph.PlotDataItem.setdata()`, which calls through PlotDataItem->setData, PlotDataItem->updateItems. At some point in the call stack, the default value for `shadowPen` is being inserted into the kwargs, which then causes the specious calling of setShadowPen. Anyways, if we check if shadowPen is a value other then none, this doesn't happen.
This commit is contained in:
parent
a4fe86a52d
commit
17e90af36c
@ -69,8 +69,7 @@ class PlotCurveItem(GraphicsObject):
|
|||||||
'mouseWidth': 8, # width of shape responding to mouse click
|
'mouseWidth': 8, # width of shape responding to mouse click
|
||||||
'compositionMode': None,
|
'compositionMode': None,
|
||||||
}
|
}
|
||||||
if 'pen' not in kargs:
|
|
||||||
self.opts['pen'] = fn.mkPen('w')
|
|
||||||
self.setClickable(kargs.get('clickable', False))
|
self.setClickable(kargs.get('clickable', False))
|
||||||
self.setData(*args, **kargs)
|
self.setData(*args, **kargs)
|
||||||
|
|
||||||
@ -390,11 +389,11 @@ class PlotCurveItem(GraphicsObject):
|
|||||||
self.opts['connect'] = kargs['connect']
|
self.opts['connect'] = kargs['connect']
|
||||||
if 'pen' in kargs:
|
if 'pen' in kargs:
|
||||||
self.setPen(kargs['pen'])
|
self.setPen(kargs['pen'])
|
||||||
if 'shadowPen' in kargs:
|
if 'shadowPen' in kargs and kargs['shadowPen'] is not None:
|
||||||
self.setShadowPen(kargs['shadowPen'])
|
self.setShadowPen(kargs['shadowPen'])
|
||||||
if 'fillLevel' in kargs:
|
if 'fillLevel' in kargs and kargs['fillLevel'] is not None:
|
||||||
self.setFillLevel(kargs['fillLevel'])
|
self.setFillLevel(kargs['fillLevel'])
|
||||||
if 'brush' in kargs:
|
if 'brush' in kargs and kargs['brush'] is not None:
|
||||||
self.setBrush(kargs['brush'])
|
self.setBrush(kargs['brush'])
|
||||||
if 'antialias' in kargs:
|
if 'antialias' in kargs:
|
||||||
self.opts['antialias'] = kargs['antialias']
|
self.opts['antialias'] = kargs['antialias']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user