|
From: <cpa...@ce...> - 2016-05-17 11:49:28
|
From: cpascual <cpa...@ce...>
---
lib/taurus/qt/qtgui/extra_guiqwt/taurustrend2d.py | 87 +++++++++++++----------
lib/taurus/qt/qtgui/extra_guiqwt/tools.py | 58 +++++++++------
2 files changed, 85 insertions(+), 60 deletions(-)
diff --git a/lib/taurus/qt/qtgui/extra_guiqwt/taurustrend2d.py b/lib/taurus/qt/qtgui/extra_guiqwt/taurustrend2d.py
index f767fa2..a941d91 100644
--- a/lib/taurus/qt/qtgui/extra_guiqwt/taurustrend2d.py
+++ b/lib/taurus/qt/qtgui/extra_guiqwt/taurustrend2d.py
@@ -33,28 +33,30 @@ from taurus.external.qt import Qt
import taurus.core
from taurus.qt.qtgui.base import TaurusBaseWidget
from taurus.qt.qtgui.extra_guiqwt.image import TaurusTrend2DItem
-from taurus.qt.qtgui.extra_guiqwt.tools import TaurusModelChooserTool, TimeAxisTool, AutoScrollTool
+from taurus.qt.qtgui.extra_guiqwt.tools import (TaurusModelChooserTool,
+ TimeAxisTool, AutoScrollTool)
class TaurusTrend2DDialog(ImageDialog, TaurusBaseWidget):
- '''
+ """
This is a widget for displaying trends from 1D Taurus attributes (i.e.,
representing the variation over time of a 1D array). Sometimes this kind of
plots are also known as "spectrograms".
The widget shows a 3D plot (Z represented with colors) where the values in
the 1D array are plotted in the Y-Z plane and are stacked along the X axis.
- '''
+ """
_modifiableByUser = True
def __init__(self, parent=None, designMode=False, toolbar=True,
stackMode='deltatime', buffersize=512, options=None, **kwargs):
- '''see :class:`guiqwt.plot.ImageDialog` for other valid initialization parameters'''
+ """see :class:`guiqwt.plot.ImageDialog` for other valid initialization
+ parameters"""
defaultOptions = dict(lock_aspect_ratio=False)
if options is not None:
defaultOptions.update(options)
- ImageDialog.__init__(self, parent=parent,
- toolbar=toolbar, options=defaultOptions, **kwargs)
+ ImageDialog.__init__(self, parent=parent, toolbar=toolbar,
+ options=defaultOptions, **kwargs)
TaurusBaseWidget.__init__(self, "TaurusTrend2DDialog")
self.trendItem = None
self.buffersize = buffersize
@@ -76,7 +78,7 @@ class TaurusTrend2DDialog(ImageDialog, TaurusBaseWidget):
ImageDialog.keyPressEvent(self, event)
def setStackMode(self, mode):
- '''set the type of stack to be used. This determines how X values are
+ """set the type of stack to be used. This determines how X values are
interpreted:
- as timestamps ('datetime')
@@ -84,7 +86,7 @@ class TaurusTrend2DDialog(ImageDialog, TaurusBaseWidget):
- as event numbers ('event')
:param mode:(one of 'datetime', 'timedelta' or 'event')
- '''
+ """
mode = str(mode)
if mode == 'datetime':
self.add_tool(TimeAxisTool)
@@ -113,11 +115,11 @@ class TaurusTrend2DDialog(ImageDialog, TaurusBaseWidget):
self.setStackMode('datetime')
def getModelClass(self):
- '''reimplemented from :class:`TaurusBaseWidget`'''
+ """reimplemented from :class:`TaurusBaseWidget`"""
return taurus.core.taurusattribute.TaurusAttribute
def setModel(self, model):
- '''reimplemented from :class:`TaurusBaseWidget`'''
+ """reimplemented from :class:`TaurusBaseWidget`"""
plot = self.get_plot()
if self.trendItem is not None:
plot.del_item(self.trendItem)
@@ -145,56 +147,57 @@ class TaurusTrend2DDialog(ImageDialog, TaurusBaseWidget):
"dataChanged"), self.update_cross_sections)
def getModel(self):
- '''reimplemented from :class:`TaurusBaseWidget`'''
+ """reimplemented from :class:`TaurusBaseWidget`"""
if self.trendItem is None:
return None
else:
return self.trendItem.getModel()
def setUseArchiving(self, enable):
- '''enables/disables looking up in the archiver for data stored before
+ """enables/disables looking up in the archiver for data stored before
the Trend was started
- :param enable: (bool) if True, archiving values will be used if available
- '''
+ :param enable: (bool) if True, archiving values will be used if
+ available
+ """
if not self._stackMode == 'datetime':
self.info('ignoring setUseArchiving. Reason: not in X time scale')
self._useArchiving = enable
def getUseArchiving(self):
- '''whether TaurusTrend is looking for data in the archiver when needed
+ """whether TaurusTrend is looking for data in the archiver when needed
:return: (bool)
.. seealso:: :meth:`setUseArchiving`
- '''
+ """
return self._useArchiving
def resetUseArchiving(self):
- '''Same as setUseArchiving(False)'''
+ """Same as setUseArchiving(False)"""
self.setUseArchiving(False)
def setMaxDataBufferSize(self, maxSize):
- '''sets the maximum number of events that will be stacked
+ """sets the maximum number of events that will be stacked
:param maxSize: (int) the maximum limit
.. seealso:: :class:`TaurusTrendSet`
- '''
+ """
if self.trendItem is not None:
self.trendItem.setBufferSize(maxSize)
self.buffersize = maxSize
def getMaxDataBufferSize(self):
- '''returns the maximum number of events that can be plotted in the trend
+ """returns the maximum number of events that can be plotted in the trend
:return: (int)
- '''
+ """
return self.buffersize
def resetMaxDataBufferSize(self):
- '''Same as setMaxDataBufferSize(512) (i.e. 512 events)'''
+ """Same as setMaxDataBufferSize(512) (i.e. 512 events)"""
self.setMaxDataBufferSize(512)
@classmethod
@@ -215,14 +218,17 @@ class TaurusTrend2DDialog(ImageDialog, TaurusBaseWidget):
model = Qt.pyqtProperty("QString", getModel, setModel,
TaurusBaseWidget.resetModel)
# @todo uncomment this when archiving is supported
- useArchiving = Qt.pyqtProperty(
- "bool", getUseArchiving, setUseArchiving, resetUseArchiving)
- maxDataBufferSize = Qt.pyqtProperty(
- "int", getMaxDataBufferSize, setMaxDataBufferSize, resetMaxDataBufferSize)
- stackMode = Qt.pyqtProperty(
- "QString", getStackMode, setStackMode, resetStackMode)
- modifiableByUser = Qt.pyqtProperty(
- "bool", TaurusBaseWidget.isModifiableByUser, setModifiableByUser, TaurusBaseWidget.resetModifiableByUser)
+ useArchiving = Qt.pyqtProperty("bool", getUseArchiving, setUseArchiving,
+ resetUseArchiving)
+ maxDataBufferSize = Qt.pyqtProperty("int", getMaxDataBufferSize,
+ setMaxDataBufferSize,
+ resetMaxDataBufferSize)
+ stackMode = Qt.pyqtProperty("QString", getStackMode, setStackMode,
+ resetStackMode)
+ modifiableByUser = Qt.pyqtProperty("bool",
+ TaurusBaseWidget.isModifiableByUser,
+ setModifiableByUser,
+ TaurusBaseWidget.resetModifiableByUser)
def taurusTrend2DMain():
@@ -233,12 +239,19 @@ def taurusTrend2DMain():
# prepare options
parser = taurus.core.util.argparse.get_taurus_parser()
parser.set_usage("%prog [options] <model>")
- parser.set_description(
- 'a Taurus application for plotting trends of arrays (aka "spectrograms")')
- parser.add_option("-x", "--x-axis-mode", dest="x_axis_mode", default='d', metavar="t|d|e",
- help="interpret X values as timestamps (t), time deltas (d) or event numbers (e). Accepted values: t|d|e")
+ parser.set_description('a Taurus application for plotting trends of ' +
+ 'arrays (aka "spectrograms")')
+ parser.add_option("-x", "--x-axis-mode", dest="x_axis_mode", default='d',
+ metavar="t|d|e",
+ help=("interpret X values as timestamps (t), " +
+ "time deltas (d) or event numbers (e). " +
+ "Accepted values: t|d|e")
+ )
parser.add_option("-b", "--buffer", dest="max_buffer_size", default='512',
- help="maximum number of values to be stacked (when reached, the oldest values will be discarded)")
+ help=("maximum number of values to be stacked " +
+ "(when reached, the oldest values will be " +
+ "discarded)")
+ )
parser.add_option("-a", "--use-archiving",
action="store_true", dest="use_archiving", default=False)
parser.add_option("--demo", action="store_true", dest="demo",
@@ -246,8 +259,8 @@ def taurusTrend2DMain():
parser.add_option("--window-name", dest="window_name",
default="Taurus Trend 2D", help="Name of the window")
- app = TaurusApplication(
- cmd_line_parser=parser, app_name="Taurus Trend 2D", app_version=taurus.Release.version)
+ app = TaurusApplication(cmd_line_parser=parser, app_name="Taurus Trend 2D",
+ app_version=taurus.Release.version)
args = app.get_command_line_args()
options = app.get_command_line_options()
diff --git a/lib/taurus/qt/qtgui/extra_guiqwt/tools.py b/lib/taurus/qt/qtgui/extra_guiqwt/tools.py
index 5df5554..124f57a 100644
--- a/lib/taurus/qt/qtgui/extra_guiqwt/tools.py
+++ b/lib/taurus/qt/qtgui/extra_guiqwt/tools.py
@@ -30,7 +30,8 @@ __docformat__ = 'restructuredtext'
from taurus.external.qt import Qt
-from guiqwt.tools import CommandTool, ToggleTool, DefaultToolbarID, QActionGroup, add_actions
+from guiqwt.tools import (CommandTool, ToggleTool, DefaultToolbarID,
+ QActionGroup, add_actions)
from guiqwt.signals import SIG_ITEMS_CHANGED
from taurus.core.taurusbasetypes import TaurusElementType
@@ -45,12 +46,14 @@ from taurus.qt.qtgui.plot import DateTimeScaleEngine
class TaurusCurveChooserTool(CommandTool):
"""
- A tool that shows the Taurus Model Chooser to create/edit the taurus curves of a plot
+ A tool that shows the Taurus Model Chooser to create/edit the taurus curves
+ of a plot
"""
def __init__(self, manager, toolbar_id=DefaultToolbarID):
super(TaurusCurveChooserTool, self).__init__(
- manager, "Taurus Models...", getIcon(":/taurus.png"), toolbar_id=toolbar_id)
+ manager, "Taurus Models...", getIcon(":/taurus.png"),
+ toolbar_id=toolbar_id)
def activate_command(self, plot, checked):
"""Activate tool"""
@@ -65,8 +68,8 @@ class TaurusCurveChooserTool(CommandTool):
# create curve items and add them to the plot
for c in confs:
if c.taurusparam.yModel:
- item = make.pcurve(
- c.taurusparam.xModel or None, c.taurusparam.yModel, c.curveparam)
+ item = make.pcurve(c.taurusparam.xModel or None,
+ c.taurusparam.yModel, c.curveparam)
plot.add_item(item)
if c.axesparam is not None:
c.axesparam.update_axes(item)
@@ -74,12 +77,14 @@ class TaurusCurveChooserTool(CommandTool):
class TaurusImageChooserTool(CommandTool):
"""
- A tool that shows the Taurus Model Chooser and adds new taurus image items to a plot
+ A tool that shows the Taurus Model Chooser and adds new taurus image items
+ to a plot
"""
def __init__(self, manager, toolbar_id=DefaultToolbarID):
super(TaurusImageChooserTool, self).__init__(
- manager, "Add Taurus images...", getIcon(":/taurus.png"), toolbar_id=toolbar_id)
+ manager, "Add Taurus images...", getIcon(":/taurus.png"),
+ toolbar_id=toolbar_id)
def activate_command(self, plot, checked):
"""Activate tool"""
@@ -95,19 +100,24 @@ class TaurusImageChooserTool(CommandTool):
class TaurusModelChooserTool(CommandTool):
"""
- A tool that shows the Taurus Model Chooser and sets the chosen model on the manager
+ A tool that shows the Taurus Model Chooser and sets the chosen model on
+ the manager
"""
def __init__(self, manager, toolbar_id=DefaultToolbarID, singleModel=False):
super(TaurusModelChooserTool, self).__init__(
- manager, "Change Taurus Model...", getIcon(":/taurus.png"), toolbar_id=toolbar_id)
+ manager, "Change Taurus Model...", getIcon(":/taurus.png"),
+ toolbar_id=toolbar_id)
self.singleModel = singleModel
def activate_command(self, plot, checked):
"""Activate tool"""
# show a dialog
- models, ok = TaurusModelChooser.modelChooserDlg(parent=plot, selectables=[
- TaurusElementType.Attribute], singleModel=self.singleModel)
+ models, ok = TaurusModelChooser.modelChooserDlg(
+ parent=plot,
+ selectables=[TaurusElementType.Attribute],
+ singleModel=self.singleModel
+ )
if ok:
if self.singleModel:
if models:
@@ -124,10 +134,9 @@ class TimeAxisTool(CommandTool):
"""
def __init__(self, manager):
- super(TimeAxisTool, self).__init__(manager, "Time Scale",
- icon=getIcon(
- ":/status/awaiting.svg"),
- tip=None, toolbar_id=None)
+ super(TimeAxisTool, self).__init__(
+ manager, "Time Scale", icon=getIcon(":/status/awaiting.svg"),
+ tip=None, toolbar_id=None)
self.action.setEnabled(True)
def create_action_menu(self, manager):
@@ -152,16 +161,17 @@ class TimeAxisTool(CommandTool):
def _getAxesUseTime(self, plot):
"""
- Returns a tuple (xIsTime, yIsTime) where xIsTime is True if the plot's active x
- axis uses a TimeScale. yIsTime is True if plot's active y axis uses a Time
+ Returns a tuple (xIsTime, yIsTime) where xIsTime is True if the plot's
+ active x axis uses a TimeScale. yIsTime is True if plot's active y axis
Scale. Otherwise they are False.
"""
if plot is None:
- return (False, False)
+ return False, False
xaxis, yaxis = plot.get_active_axes()
xEngine = plot.axisScaleEngine(xaxis)
yEngine = plot.axisScaleEngine(yaxis)
- return isinstance(xEngine, DateTimeScaleEngine), isinstance(yEngine, DateTimeScaleEngine)
+ return (isinstance(xEngine, DateTimeScaleEngine),
+ isinstance(yEngine, DateTimeScaleEngine))
def update_status(self, plot):
active_scale = self._getAxesUseTime(plot)
@@ -209,8 +219,10 @@ class AutoScrollTool(ToggleTool):
always visible"""
def __init__(self, manager, scrollFactor=0.2, toolbar_id=None):
- super(AutoScrollTool, self).__init__(manager, title='Auto Scroll', icon=None,
- tip='Force X scale to always show the last value', toolbar_id=toolbar_id)
+ super(AutoScrollTool, self).__init__(
+ manager, title='Auto Scroll', icon=None,
+ tip='Force X scale to always show the last value',
+ toolbar_id=toolbar_id)
self.scrollFactor = scrollFactor
def register_plot(self, baseplot):
@@ -229,7 +241,8 @@ class AutoScrollTool(ToggleTool):
'scrollRequested'), self.onScrollRequested)
def getScrollItems(self, plot):
- return [item for item in plot.get_items() if isinstance(item, (TaurusTrendItem, TaurusTrend2DItem))]
+ return [item for item in plot.get_items()
+ if isinstance(item, (TaurusTrendItem, TaurusTrend2DItem))]
def onScrollRequested(self, plot, axis, value):
scalemin, scalemax = plot.get_axis_limits(axis)
@@ -245,7 +258,6 @@ class AutoScrollTool(ToggleTool):
def testTool(tool):
from taurus.qt.qtgui.application import TaurusApplication
from guiqwt.plot import CurveDialog
- import sys
app = TaurusApplication()
win = CurveDialog(edit=False, toolbar=True)
--
2.8.1
|