pvplot 1.2.3__tar.gz → 1.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pvplot
3
- Version: 1.2.3
3
+ Version: 1.3.0
4
4
  Summary: Plotting tool for EPICS PVs, ADO and LITE parameters
5
5
  Project-URL: Homepage, https://github.com/ASukhanov/pvplot
6
6
  Project-URL: Bug Tracker, https://github.com/ASukhanov/pvplot/issues
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python3
2
2
  """Plotting package for EPICS PVs, ADO and LITE parameters.
3
3
  """
4
- __version__ = 'v1.2.3 2024-07-29'# fix: config-less plotting
4
+ __version__ = 'v1.3.0 2024-07-30'# allow for disable/enable curves,
5
5
  #TODO: if backend times out the gui is not responsive
6
6
  #TODO: move Add Dataset to Dataset options
7
7
  #TODO: add dataset arithmetics
@@ -245,6 +245,7 @@ class Dataset():
245
245
  self.pxMode = None
246
246
  self.timeAxis = False
247
247
  self.statistics = {}
248
+ self.enabled = True
248
249
 
249
250
  # ``````````````````` Add plotItem ``````````````````````````````````````
250
251
  #dockNum = name.split('.')[0]
@@ -320,6 +321,12 @@ class Dataset():
320
321
  self.plotWidget.addItem(self.plotItem)
321
322
  self.lastTimePlotted = 0.
322
323
 
324
+ def add_plot(self):
325
+ self.plotWidget.addItem(self.plotItem)
326
+
327
+ def remove_plot(self):
328
+ self.plotWidget.removeItem(self.plotItem)
329
+
323
330
  def __str__(self):
324
331
  return f'Dataset {self.name}, x: {self.data[X].shape}'
325
332
 
@@ -345,9 +352,10 @@ class Dataset():
345
352
  self.viewBox.setXRange(self.viewXRange[0], self.viewXRange[1])
346
353
 
347
354
  def plot(self, ts):
348
- # Plot the dataset
355
+ # Plot the dataset. It may be several updates between these calls.
349
356
  if self.lastTimePlotted == ts:
350
357
  return
358
+ printv(f'>plot: {self.name}')
351
359
  self.lastTimePlotted = ts
352
360
  #print(f'>plot: {self.name, {self.dataPtr}, round(ts,3)}')
353
361
  x = self.data[X][:self.dataPtr]
@@ -383,10 +391,11 @@ class Dataset():
383
391
  if ts:
384
392
  if ts == self.lastTimeUpdated:
385
393
  self.dataChanged = False
386
- #print(f'curve {self.name} did not change {round(ts,3)}')
387
- if time2plot:
388
- self.plot(ts)
394
+ printv(f'curve {self.name} did not change {round(ts,3)}')
395
+ #if time2plot:
396
+ # self.plot(ts)
389
397
  return
398
+ printv(f'update_plot: {self.name,curvePars}')
390
399
  self.dataChanged = True
391
400
  self.lastTimeUpdated = ts
392
401
  #printv(f'update_plot: {curvePars}, data:{yd}')
@@ -524,6 +533,7 @@ class MapOfDatasets():
524
533
  pnameAndCount.append((adoPar,count))
525
534
  printv('adding '+str(pnameAndCount)+' to datasets['+curveName+']')
526
535
  MapOfDatasets.dtsDict[curveName] = Dataset(dockNum, curveName, pnameAndCount)
536
+ PVPlot.mapOfCurves[dockNum].append(curveName)
527
537
  printv(f'MapOfDatasets: {[(k,v.adoPars) for k ,v in MapOfDatasets.dtsDict.items()]}')
528
538
  return 0
529
539
 
@@ -698,32 +708,37 @@ class CustomViewBox(pg.ViewBox):
698
708
  dlg = QW.QDialog()
699
709
  dlg.setWindowTitle(f"Dataset of dock{self.dockNum}")
700
710
  dlg.setWindowModality(QtCore.Qt.ApplicationModal)
701
- dlgSize = 500,200
702
- dlg.setMinimumSize(*dlgSize)
703
- rowCount,columnCount = 0,6
711
+ rowCount,columnCount = 0,8
704
712
  tbl = QW.QTableWidget(rowCount, columnCount, dlg)
705
713
  tbl.setHorizontalHeaderLabels(
706
- ['Name','PV','Color','Width','Symbol','Size'])
707
- widths = ( 50, 100, 30, 80, 40, 80)
714
+ ['Enb','Name','PV','Color','Width','Symbol','Size',''])
715
+ widths = (30, 50, 100, 30, 80, 40, 80,80)
708
716
  for column,width in enumerate(widths):
709
717
  tbl.setColumnWidth(column, width)
710
718
  tbl.setShowGrid(False)
711
719
  tbl.setSizeAdjustPolicy(
712
720
  QW.QAbstractScrollArea.AdjustToContents)
713
- tbl.resize(*dlgSize)
714
721
 
715
- listOfItems = PVPlot.mapOfPlotWidgets[self.dockNum].getPlotItem().listDataItems()
716
- for row,dataitem in enumerate(listOfItems):
722
+ for row,curveName in enumerate(PVPlot.mapOfCurves[self.dockNum]):
717
723
  tbl.insertRow(row)
718
- curveName = dataitem.name()
719
724
  printv(f'curveName:{curveName}')
720
- col = 0
721
725
  dataset = MapOfDatasets.dtsDict[curveName]
726
+ col = 0
727
+ cbox = QW.QCheckBox()
728
+ cbox.setChecked(dataset.enabled)
729
+ #cbox.stateChanged.connect(lambda x: self.enable_dataset(x))
730
+ cbox.stateChanged.connect(self.enable_dataset)
731
+ cbox.setObjectName(curveName)
732
+ tbl.setCellWidget(row, col, cbox)
733
+
734
+ col+=1
722
735
  adoparName = dataset.adoPars[0][0]
723
736
  tbl.setItem(row, col, QW.QTableWidgetItem(curveName))
737
+
724
738
  col+=1
725
739
  printv(f'dataset:{adoparName}')
726
740
  tbl.setItem(row, col, QW.QTableWidgetItem(adoparName))
741
+
727
742
  col+=1
728
743
  # color button for line
729
744
  colorButton = pg.ColorButton(color=dataset.pen.color())
@@ -731,6 +746,7 @@ class CustomViewBox(pg.ViewBox):
731
746
  colorButton.sigColorChanging.connect(lambda x:
732
747
  change_plotOption(str(self.sender().objectName()),color=x.color()))
733
748
  tbl.setCellWidget(row, col, colorButton)
749
+
734
750
  col+=1
735
751
  # slider for changing the line width
736
752
  widthSlider = QW.QSlider()
@@ -741,6 +757,7 @@ class CustomViewBox(pg.ViewBox):
741
757
  widthSlider.valueChanged.connect(lambda x:
742
758
  change_plotOption(str(self.sender().objectName()),width=x))
743
759
  tbl.setCellWidget(row, col, widthSlider)
760
+
744
761
  col+=1
745
762
  # symbol, selected from a comboBox
746
763
  self.symbol = QW.QComboBox() # TODO: why self?
@@ -748,6 +765,7 @@ class CustomViewBox(pg.ViewBox):
748
765
  self.symbol.setObjectName(curveName)
749
766
  self.symbol.currentIndexChanged.connect(self.set_symbol)
750
767
  tbl.setCellWidget(row, col, self.symbol)
768
+
751
769
  col+=1
752
770
  # slider for changing the line width
753
771
  symbolSizeSlider = QW.QSlider()
@@ -758,13 +776,11 @@ class CustomViewBox(pg.ViewBox):
758
776
  symbolSizeSlider.valueChanged.connect(lambda x:
759
777
  change_plotOption(str(self.sender().objectName()),symbolSize=x))
760
778
  tbl.setCellWidget(row, col, symbolSizeSlider)
761
- col+=1
762
- # color button for symbol
763
- symbolColorButton = pg.ColorButton(color=dataset.pen.color())
764
- symbolColorButton.setObjectName(curveName)
765
- symbolColorButton.sigColorChanging.connect(lambda x:
766
- change_plotOption(str(self.sender().objectName()),scolor=x.color()))
767
- tbl.setCellWidget(row, col,symbolColorButton)
779
+
780
+ #dlg.resize(tbl.width(),tbl.height())
781
+ dialogWidth = tbl.horizontalHeader().length() + 24
782
+ dialogHeight= tbl.verticalHeader().length() + 24
783
+ dlg.setMinimumSize(dialogWidth, dialogHeight)
768
784
  dlg.exec_()
769
785
 
770
786
  def set_symbol(self, x):
@@ -838,6 +854,15 @@ class CustomViewBox(pg.ViewBox):
838
854
  PVPlot.yProjectionWindow.setWindowTitle(
839
855
  f'Vertical projection of {self.dataset.adoPars[0][0].rsplit(":",1)[1]}')
840
856
  self.dataset.show_yProjection()
857
+
858
+ def enable_dataset(self, state):
859
+ dtsetName = str(self.sender().objectName())
860
+ #print(f'enable_dataset {dtsetName, (state==QtCore.Qt.Checked)}')
861
+ dataset = MapOfDatasets.dtsDict[dtsetName]
862
+ enabled = (state==QtCore.Qt.Checked)
863
+ dataset.enabled = enabled
864
+ dataset.add_plot() if enabled else dataset.remove_plot()
865
+ #set_legend(self.dockNum, enabled)# deletes all legend items
841
866
  #,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
842
867
 
843
868
  def callback(args):
@@ -872,6 +897,7 @@ def add_curves(dockNum:int, curveMap:str):
872
897
  else:
873
898
  PVPlot.dockArea.addDock(PVPlot.mapOfDocks[dockNum],
874
899
  'top', PVPlot.mapOfDocks[0], closable=True) #TODO:closable does not work
900
+ PVPlot.mapOfCurves[dockNum] = []
875
901
  if MapOfDatasets.add(dockNum, curveMap):
876
902
  printe(f'in add_curves: {dockNum, curveMap}')
877
903
 
@@ -909,8 +935,9 @@ def parse_input_parameters(pargs):
909
935
  class PVPlot():
910
936
  config = None
911
937
  pargs = None
912
- mapOfPlotWidgets = {}
913
- mapOfDocks = {}
938
+ mapOfPlotWidgets = {}# active plotItems
939
+ mapOfDocks = {}# dockAreas
940
+ mapOfCurves = {}
914
941
  padding = 0.1
915
942
  scaleUnits = [[1,'Sample'],[1,'Count']]
916
943
  subscribedParMap = {}
@@ -1030,8 +1057,11 @@ class PVPlot():
1030
1057
  PVPlot.stopped = state
1031
1058
  if state == True:
1032
1059
  PVPlot.qTimer.stop()
1060
+ title = PVPlot.qWin.windowTitle()+' Stopped'
1033
1061
  else:
1034
1062
  PVPlot.qTimer.start(int(PVPlot.pargs.sleepTime*1000))
1063
+ title = PVPlot.qWin.windowTitle().replace(' Stopped','')
1064
+ PVPlot.qWin.setWindowTitle(title)
1035
1065
 
1036
1066
  #``````````Shorthcut handlers
1037
1067
  def actionHelp():
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pvplot"
7
- version = "1.2.3"
7
+ version = "1.3.0"
8
8
  authors = [
9
9
  { name="Andrei Sukhanov", email="cyxandr@gmail.com" },
10
10
  ]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes