1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
from argparse import Namespace
from collections import OrderedDict
from time import perf_counter
from pyqtgraph.Qt import QtCore
# Avoid clash with module name
examples_ = OrderedDict([
('Command-line usage', 'CLIexample.py'),
('Basic Plotting', Namespace(filename='Plotting.py', recommended=True)),
('ImageView', Namespace(filename='ImageView.py', recommended=True)),
('ParameterTree', Namespace(filename='parametertree.py', recommended=True)),
('Plotting Datasets', 'MultiDataPlot.py'),
('Parameter-Function Interaction', 'InteractiveParameter.py'),
('Crosshair / Mouse interaction', 'crosshair.py'),
('Data Slicing', 'DataSlicing.py'),
('Plot Customization', 'customPlot.py'),
('Timestamps on x axis', 'DateAxisItem.py'),
('Image Analysis', Namespace(filename='imageAnalysis.py', recommended=True)),
('Matrix Display', 'MatrixDisplayExample.py'),
('ViewBox Features', Namespace(filename='ViewBoxFeatures.py', recommended=True)),
('Dock widgets', 'dockarea.py'),
('Console', 'ConsoleWidget.py'),
('Console - Exception inspection', 'console_exception_inspection.py'),
('Rich Jupyter Console', 'jupyter_console_example.py'),
('Histograms', 'histogram.py'),
('Beeswarm plot', 'beeswarm.py'),
('Symbols', 'Symbols.py'),
('Auto-range', 'PlotAutoRange.py'),
('Remote Plotting', 'RemoteSpeedTest.py'),
('Scrolling plots', 'scrollingPlots.py'),
('HDF5 big data', 'hdf5.py'),
('Glow', 'glow.py'),
('Demos', OrderedDict([
('Optics', 'optics_demos.py'),
('Special relativity', 'relativity_demo.py'),
('Verlet chain', 'verlet_chain_demo.py'),
('Koch Fractal', 'fractal.py'),
])),
('Colors', OrderedDict([
('Color Maps', 'colorMaps.py'),
('Color Map Linearization', 'colorMapsLinearized.py'),
('Color Gradient Plots', 'ColorGradientPlots.py')
])),
('GraphicsItems', OrderedDict([
('Scatter Plot', 'ScatterPlot.py'),
#('PlotItem', 'PlotItem.py'),
('InfiniteLine', 'InfiniteLine.py'),
('IsocurveItem', 'isocurve.py'),
('GraphItem', 'GraphItem.py'),
('ErrorBarItem', 'ErrorBarItem.py'),
('FillBetweenItem', 'FillBetweenItem.py'),
('ImageItem - video', 'ImageItem.py'),
('ImageItem - draw', 'Draw.py'),
('ColorBarItem','ColorBarItem.py'),
('Non-uniform Image', 'NonUniformImage.py'),
('Region-of-Interest', 'ROIExamples.py'),
('Bar Graph', 'BarGraphItem.py'),
('GraphicsLayout', 'GraphicsLayout.py'),
('LegendItem', 'Legend.py'),
('Text Item', 'text.py'),
('Linked Views', 'linkedViews.py'),
('Arrow', 'Arrow.py'),
('ViewBox', 'ViewBoxFeatures.py'),
('AxisItem - label overlap', 'AxisItem_label_overlap.py'),
('Custom Graphics', 'customGraphicsItem.py'),
('Labeled Graph', 'CustomGraphItem.py'),
('PColorMeshItem', 'PColorMeshItem.py'),
])),
('Benchmarks', OrderedDict([
('Video speed test', 'VideoSpeedTest.py'),
('Line Plot update', 'PlotSpeedTest.py'),
('Scatter Plot update', 'ScatterPlotSpeedTest.py'),
('Multiple plots', 'MultiPlotSpeedTest.py'),
])),
('3D Graphics', OrderedDict([
('Volumetric', 'GLVolumeItem.py'),
('Isosurface', 'GLIsosurface.py'),
('Surface Plot', 'GLSurfacePlot.py'),
('Scatter Plot', 'GLScatterPlotItem.py'),
('Shaders', 'GLshaders.py'),
('Line Plot', 'GLLinePlotItem.py'),
('Mesh', 'GLMeshItem.py'),
('Image', 'GLImageItem.py'),
('Text', 'GLTextItem.py'),
('BarGraph', 'GLBarGraphItem.py'),
('Painter', 'GLPainterItem.py'),
('Gradient Legend', 'GLGradientLegendItem.py')
])),
('Widgets', OrderedDict([
('PlotWidget', 'PlotWidget.py'),
('SpinBox', 'SpinBox.py'),
('ConsoleWidget', 'ConsoleWidget.py'),
('Histogram / lookup table', 'HistogramLUT.py'),
('TreeWidget', 'TreeWidget.py'),
('ScatterPlotWidget', 'ScatterPlotWidget.py'),
('DataTreeWidget', 'DataTreeWidget.py'),
('GradientWidget', 'GradientWidget.py'),
('TableWidget', 'TableWidget.py'),
('ColorButton', 'ColorButton.py'),
#('CheckTable', '../widgets/CheckTable.py'),
#('VerticalLabel', '../widgets/VerticalLabel.py'),
('JoystickButton', 'JoystickButton.py'),
])),
('Flowcharts', 'Flowchart.py'),
('Custom Flowchart Nodes', 'FlowchartCustomNode.py'),
])
# don't care about ordering
# but actually from Python 3.7, dict is ordered
others = dict([
('logAxis', 'logAxis.py'),
('PanningPlot', 'PanningPlot.py'),
('MultiplePlotAxes', 'MultiplePlotAxes.py'),
('ROItypes', 'ROItypes.py'),
('ScaleBar', 'ScaleBar.py'),
('ViewBox', 'ViewBox.py'),
('GradientEditor', 'GradientEditor.py'),
('GLViewWidget', 'GLViewWidget.py'),
('DiffTreeWidget', 'DiffTreeWidget.py'),
('RemoteGraphicsView', 'RemoteGraphicsView.py'),
('contextMenu', 'contextMenu.py'),
('designerExample', 'designerExample.py'),
('DateAxisItem_QtDesigner', 'DateAxisItem_QtDesigner.py'),
('GraphicsScene', 'GraphicsScene.py'),
('MouseSelection', 'MouseSelection.py'),
])
# examples that are subsumed into other examples
trivial = dict([
('SimplePlot', 'SimplePlot.py'), # Plotting.py
('LogPlotTest', 'LogPlotTest.py'), # Plotting.py
('ViewLimits', 'ViewLimits.py'), # ViewBoxFeatures.py
])
# examples that are not suitable for CI testing
skiptest = dict([
('ProgressDialog', 'ProgressDialog.py'), # modal dialog
])
class FrameCounter(QtCore.QObject):
sigFpsUpdate = QtCore.Signal(object)
def __init__(self, interval=1000):
super().__init__()
self.count = 0
self.last_update = 0
self.interval = interval
def update(self):
self.count += 1
if self.last_update == 0:
self.last_update = perf_counter()
self.startTimer(self.interval)
def timerEvent(self, evt):
now = perf_counter()
elapsed = now - self.last_update
fps = self.count / elapsed
self.last_update = now
self.count = 0
self.sigFpsUpdate.emit(fps)
|