xarray-graph 0.1.2__py3-none-any.whl → 0.2.0__py3-none-any.whl

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.
@@ -0,0 +1,52 @@
1
+
2
+
3
+ import numpy as np
4
+ import scipy as sp
5
+ import lmfit
6
+ from qtpy.QtCore import *
7
+ from qtpy.QtGui import *
8
+ from qtpy.QtWidgets import *
9
+ from pyqt_ext import *
10
+ from pyqtgraph_ext import *
11
+
12
+
13
+ class AxisRegionsManager():
14
+
15
+ def __init__(self):
16
+ self.regions: list[dict] = []
17
+ self.plots: list[Plot] = []
18
+
19
+ def update_plots_from_regions(self):
20
+ for plot in self.plots:
21
+ view: View = plot.getViewBox()
22
+ items: list[XAxisRegion] = [item for item in view.allChildren() if isinstance(item, XAxisRegion)]
23
+
24
+ for item in view.allChildren():
25
+ if isinstance(item, XAxisRegion):
26
+ view.removeItem(item)
27
+ for region in self.regions:
28
+ self.add_region(region)
29
+
30
+ def add_region(self, region: dict) -> None:
31
+ if region not in self.regions:
32
+ self.regions.append(region)
33
+ for plot in self.plots:
34
+ view: View = plot.getViewBox()
35
+ item = XAxisRegion(region.get('region', [0, 0]))
36
+ item.setText(region.get('text', ''))
37
+ item.setLabel(region.get('label', ''))
38
+ item.setIsMovable(region.get('moveable', True))
39
+ region['color'] = toColorStr(item.brush.color())
40
+ region['line_color'] = toColorStr(item.pen.color())
41
+ item._data = region
42
+ view.addItem(item)
43
+ item.setFontSize(self._textitem_fontsize_spinbox.value())
44
+ # editing the region text via the popup dialog will also reset the region,
45
+ # so this will cover changes to text and label region properties too
46
+ item.sigRegionChangeFinished.connect(self._on_region_item_changed)
47
+
48
+ def update_item(self, item: XAxisRegion):
49
+ pass
50
+
51
+ def update_region_from_item(self, item: XAxisRegion):
52
+ pass