File qt_plot.py changed (mode: 100644) (index bc079bc..151af7a) |
... |
... |
Estimation graph widgets |
717 |
717 |
""" |
""" |
718 |
718 |
|
|
719 |
719 |
|
|
|
720 |
|
def get_estimation_data(estimations, metric): |
|
721 |
|
metric_dict = dict() |
|
722 |
|
# new-style: šecko leží dohromady a každý z toho |
|
723 |
|
# bere co chce a jak chce |
|
724 |
|
# ne že by to bylo nějak šetrný |
|
725 |
|
# estimation je slovníkem |
|
726 |
|
for estimation in estimations: |
|
727 |
|
# nsim musí mäť každej odhad |
|
728 |
|
# pokud nemá - je třeba jej prostě opravit |
|
729 |
|
nsim = estimation['nsim'] |
|
730 |
|
try: |
|
731 |
|
if estimation[metric] > 0: |
|
732 |
|
metric_dict[nsim] = estimation[metric] |
|
733 |
|
except KeyError as e: |
|
734 |
|
pass #print(self.__class__.__name__ + ":", repr(e)) |
|
735 |
|
|
|
736 |
|
# nikdo neslibil, že budou v pořadí |
|
737 |
|
x = np.sort(tuple(metric_dict.keys())) |
|
738 |
|
y = np.array(tuple(metric_dict.values()))[np.argsort(tuple(metric_dict.keys()))] |
|
739 |
|
return x, y |
|
740 |
|
|
720 |
741 |
|
|
721 |
742 |
|
|
722 |
743 |
class TriEstimationGraph(pg.PlotWidget): |
class TriEstimationGraph(pg.PlotWidget): |
|
... |
... |
class SimpleSimplexEstimationGraph(pg.PlotWidget): |
820 |
841 |
self.pen_mix = self.plot(x, y, fillLevel=0, brush=(255, 165, 0)) # orange |
self.pen_mix = self.plot(x, y, fillLevel=0, brush=(255, 165, 0)) # orange |
821 |
842 |
self.pen_outside = self.plot(x, y, fillLevel=0, brush=0.8) # grey |
self.pen_outside = self.plot(x, y, fillLevel=0, brush=0.8) # grey |
822 |
843 |
self.pen_success = self.plot(x, y, fillLevel=0, brush='g') # green |
self.pen_success = self.plot(x, y, fillLevel=0, brush='g') # green |
823 |
|
self.pen_exact = self.plot(x, y, pen='b') # blue |
|
824 |
844 |
|
|
825 |
845 |
|
|
826 |
846 |
else: |
else: |
|
... |
... |
class SimpleSimplexEstimationGraph(pg.PlotWidget): |
829 |
849 |
self.pen_outside = self.plot(x, y, fillLevel=0, brush=0.8) # grey |
self.pen_outside = self.plot(x, y, fillLevel=0, brush=0.8) # grey |
830 |
850 |
self.pen_mix = self.plot(x, y, fillLevel=0, brush=(255, 165, 0)) # orange |
self.pen_mix = self.plot(x, y, fillLevel=0, brush=(255, 165, 0)) # orange |
831 |
851 |
self.pen_f = self.plot(x, y, fillLevel=0, brush='r') # red |
self.pen_f = self.plot(x, y, fillLevel=0, brush='r') # red |
832 |
|
self.pen_exact = self.plot(x, y, pen='b') # blue |
|
|
852 |
|
|
|
853 |
|
self.pen_vertex = self.plot(x, y, pen='c', name='simple') |
|
854 |
|
self.pen_weighted_vertex = self.plot(x, y, pen=(170, 170, 255), name='weighted') |
|
855 |
|
try: |
|
856 |
|
exact_name = self.black_box.pf_exact_method |
|
857 |
|
except: |
|
858 |
|
exact_name = "" |
|
859 |
|
self.pen_exact = self.plot(x, y, pen='b', name=exact_name) # blue |
833 |
860 |
|
|
834 |
861 |
|
|
835 |
862 |
self.redraw() |
self.redraw() |
|
... |
... |
class SimpleSimplexEstimationGraph(pg.PlotWidget): |
856 |
883 |
xmax = nsim |
xmax = nsim |
857 |
884 |
if nsim < xmin: |
if nsim < xmin: |
858 |
885 |
xmin = nsim |
xmin = nsim |
|
886 |
|
|
859 |
887 |
except KeyError as e: |
except KeyError as e: |
860 |
888 |
pass #print(self.__class__.__name__ + ":", repr(e)) |
pass #print(self.__class__.__name__ + ":", repr(e)) |
861 |
889 |
|
|
|
... |
... |
class SimpleSimplexEstimationGraph(pg.PlotWidget): |
876 |
904 |
self.pen_mix.setData(x, nonzero(df.failure)) |
self.pen_mix.setData(x, nonzero(df.failure)) |
877 |
905 |
self.pen_outside.setData(x, nonzero(df.failure+df.mix)) |
self.pen_outside.setData(x, nonzero(df.failure+df.mix)) |
878 |
906 |
self.pen_success.setData(x, nonzero(df.failure+df.mix+df.out)) # kontrolu, zda je to 1, nechame uživateli |
self.pen_success.setData(x, nonzero(df.failure+df.mix+df.out)) # kontrolu, zda je to 1, nechame uživateli |
879 |
|
|
|
880 |
|
|
|
881 |
|
|
|
882 |
907 |
else: |
else: |
883 |
908 |
# Update the data |
# Update the data |
884 |
909 |
self.pen_f.setData(x, df.failure) |
self.pen_f.setData(x, df.failure) |
|
... |
... |
class SimpleSimplexEstimationGraph(pg.PlotWidget): |
886 |
911 |
self.pen_outside.setData(x, df.failure+df.mix+df.out) |
self.pen_outside.setData(x, df.failure+df.mix+df.out) |
887 |
912 |
self.pen_success.setData(x, df.failure+df.mix+df.out+df.success) # kontrolu, zda je to 1, nechame uivateli |
self.pen_success.setData(x, df.failure+df.mix+df.out+df.success) # kontrolu, zda je to 1, nechame uivateli |
888 |
913 |
|
|
889 |
|
|
|
|
914 |
|
self.pen_vertex.setData(*get_estimation_data(self.black_box.estimations, 'vertex_estimation')) |
|
915 |
|
self.pen_weighted_vertex.setData(*get_estimation_data(self.black_box.estimations, 'weighted_vertex_estimation')) |
890 |
916 |
|
|
891 |
917 |
if (xmax - xmin) > 0: |
if (xmax - xmin) > 0: |
892 |
918 |
if hasattr(self.black_box, 'pf_exact'): |
if hasattr(self.black_box, 'pf_exact'): |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1585 |
1611 |
addLabel(text=' ', row=None, col=None, rowspan=1, colspan=1, **kargs) |
addLabel(text=' ', row=None, col=None, rowspan=1, colspan=1, **kargs) |
1586 |
1612 |
""" |
""" |
1587 |
1613 |
# I'd like to get access to the samplebox stuff via the container's reference, |
# I'd like to get access to the samplebox stuff via the container's reference, |
1588 |
|
# but relying to Qt's parent mechanism makes me worry. |
|
|
1614 |
|
# INHERETED by gl_plot |
1589 |
1615 |
def __init__(self, samplebox_item, parent=None, *args, **kwargs): |
def __init__(self, samplebox_item, parent=None, *args, **kwargs): |
1590 |
1616 |
super().__init__(parent) |
super().__init__(parent) |
1591 |
1617 |
# sb like samplebox, of course |
# sb like samplebox, of course |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1597 |
1623 |
self.sb_item.redraw_called.connect(self.redraw) |
self.sb_item.redraw_called.connect(self.redraw) |
1598 |
1624 |
#☺ na internetu všichni tak dělaj |
#☺ na internetu všichni tak dělaj |
1599 |
1625 |
self.setup() |
self.setup() |
1600 |
|
|
|
|
1626 |
|
|
|
1627 |
|
# INHERETED by gl_plot |
1601 |
1628 |
def setup(self): |
def setup(self): |
1602 |
1629 |
# model_space='Rn', sampling_space=None, p_norm=1, budget=20000 |
# model_space='Rn', sampling_space=None, p_norm=1, budget=20000 |
1603 |
1630 |
params = [{'name': 'method', 'type': 'list', 'values': ['Voronoi_tesselation','Voronoi_2_point_estimation'], 'value': 'Voronoi_2_point_estimation'}] |
params = [{'name': 'method', 'type': 'list', 'values': ['Voronoi_tesselation','Voronoi_2_point_estimation'], 'value': 'Voronoi_2_point_estimation'}] |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1622 |
1649 |
self.ptree = pg.parametertree.ParameterTree() |
self.ptree = pg.parametertree.ParameterTree() |
1623 |
1650 |
self.ptree.setParameters(self.param, showTop=False) |
self.ptree.setParameters(self.param, showTop=False) |
1624 |
1651 |
|
|
1625 |
|
self.addWidget(self.ptree, row=0, col=0, colspan=2) |
|
|
1652 |
|
self.addWidget(self.ptree, row=0, col=0, colspan=3) |
1626 |
1653 |
|
|
1627 |
1654 |
|
|
1628 |
1655 |
self.btn = QtGui.QPushButton('estimate') |
self.btn = QtGui.QPushButton('estimate') |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1633 |
1660 |
self.addWidget(self.btn2, row=1, col=1) |
self.addWidget(self.btn2, row=1, col=1) |
1634 |
1661 |
self.btn2.clicked.connect(self.recolor) |
self.btn2.clicked.connect(self.recolor) |
1635 |
1662 |
|
|
|
1663 |
|
self.btn3 = QtGui.QPushButton('hide') |
|
1664 |
|
self.addWidget(self.btn3, row=1, col=2) |
|
1665 |
|
self.btn3.clicked.connect(self.hide) |
|
1666 |
|
|
1636 |
1667 |
# self.autorun = QtGui.QCheckBox('Run with the box') |
# self.autorun = QtGui.QCheckBox('Run with the box') |
1637 |
1668 |
# self.addWidget(self.autorun, row=1, col=1) |
# self.addWidget(self.autorun, row=1, col=1) |
1638 |
1669 |
|
|
1639 |
1670 |
self.table = pg.TableWidget(sortable=False) |
self.table = pg.TableWidget(sortable=False) |
1640 |
|
self.addWidget(self.table, row=2, col=0, colspan=2) |
|
|
1671 |
|
self.addWidget(self.table, row=2, col=0, colspan=3) |
1641 |
1672 |
|
|
1642 |
1673 |
# pro začatek postačí |
# pro začatek postačí |
1643 |
1674 |
self.cells = [] |
self.cells = [] |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1646 |
1677 |
self.p_cell_max = {'success':0, 'failure':0} |
self.p_cell_max = {'success':0, 'failure':0} |
1647 |
1678 |
|
|
1648 |
1679 |
|
|
1649 |
|
|
|
|
1680 |
|
# INHERETED by gl_plot |
1650 |
1681 |
def on_box_run(self, *args, **kwargs): |
def on_box_run(self, *args, **kwargs): |
1651 |
1682 |
# je třeba zkontrolovat autorun a restartovat výpočet |
# je třeba zkontrolovat autorun a restartovat výpočet |
1652 |
1683 |
if self.param.getValues()['Run with the box'][0]: |
if self.param.getValues()['Run with the box'][0]: |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1654 |
1685 |
#else: |
#else: |
1655 |
1686 |
#self.self_clear() |
#self.self_clear() |
1656 |
1687 |
|
|
|
1688 |
|
# INHERETED by gl_plot |
|
1689 |
|
def hide(self): |
|
1690 |
|
for nodes, plot_item, cell_stats in self.cells: |
|
1691 |
|
plot_item.hide() |
|
1692 |
|
# keep the GUI responsive :) |
|
1693 |
|
#self.sb_item.app.processEvents() |
|
1694 |
|
|
|
1695 |
|
# INHERETED by gl_plot |
1657 |
1696 |
def redraw(self, *args, **kwargs): |
def redraw(self, *args, **kwargs): |
1658 |
1697 |
self.cells.clear() |
self.cells.clear() |
1659 |
1698 |
self.p_cell_max['success'] = 0 |
self.p_cell_max['success'] = 0 |
1660 |
1699 |
self.p_cell_max['failure'] = 0 |
self.p_cell_max['failure'] = 0 |
1661 |
1700 |
|
|
1662 |
|
# I'll rename after main widget refactoring |
|
|
1701 |
|
## I'll rename after main widget refactoring |
|
1702 |
|
# refactoring already done, why I should rename? |
|
1703 |
|
# INHERETED by gl_plot |
1663 |
1704 |
def recolor(self): |
def recolor(self): |
1664 |
1705 |
# indikace |
# indikace |
1665 |
1706 |
#self.setDisabled(True) |
#self.setDisabled(True) |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1683 |
1724 |
|
|
1684 |
1725 |
|
|
1685 |
1726 |
def on_space_changed(self, *args, **kwargs): |
def on_space_changed(self, *args, **kwargs): |
1686 |
|
# asi stači překreslit propísky z tri_bound'ov |
|
1687 |
|
pass |
|
|
1727 |
|
# teď tečičky |
|
1728 |
|
for nodes, plot_item, cell_stats in self.cells: |
|
1729 |
|
pos = getattr(nodes, self.sb_item.space) |
|
1730 |
|
plot_item.setData(pos) |
1688 |
1731 |
|
|
1689 |
1732 |
|
|
|
1733 |
|
# INHERETED by gl_plot |
1690 |
1734 |
def self_clear(self): |
def self_clear(self): |
1691 |
1735 |
# odebereme prvky-propísky z hlavního plotu |
# odebereme prvky-propísky z hlavního plotu |
1692 |
1736 |
for nodes, plot_item, cell_stats in self.cells: |
for nodes, plot_item, cell_stats in self.cells: |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1696 |
1740 |
|
|
1697 |
1741 |
|
|
1698 |
1742 |
|
|
1699 |
|
|
|
|
1743 |
|
# INHERETED by gl_plot |
1700 |
1744 |
def run_stm(self): |
def run_stm(self): |
1701 |
1745 |
# indikace |
# indikace |
1702 |
1746 |
#self.setDisabled(True) |
#self.setDisabled(True) |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1755 |
1799 |
if nodes and cell_stats provided we will add them to self.cells |
if nodes and cell_stats provided we will add them to self.cells |
1756 |
1800 |
otherwise function redraw items in self.cells |
otherwise function redraw items in self.cells |
1757 |
1801 |
""" |
""" |
1758 |
|
|
|
|
1802 |
|
plot_widget = self.sb_item.central_widget |
1759 |
1803 |
if nodes is None: |
if nodes is None: |
1760 |
1804 |
for cell in self.cells: |
for cell in self.cells: |
1761 |
1805 |
nodes, plot_item, cell_stats = cell |
nodes, plot_item, cell_stats = cell |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1764 |
1808 |
# protože nikdo neví co tam bylo před tím |
# protože nikdo neví co tam bylo před tím |
1765 |
1809 |
# takhle, nechce se mi drbat s tím, co tam bylo před tím |
# takhle, nechce se mi drbat s tím, co tam bylo před tím |
1766 |
1810 |
# komplikace ze strany pyqtgraph |
# komplikace ze strany pyqtgraph |
1767 |
|
self.sb_item.plotWidget.removeItem(plot_item) |
|
|
1811 |
|
plot_widget.removeItem(plot_item) |
1768 |
1812 |
|
|
1769 |
1813 |
# bacha, potřebuji prvek uložiť in-place |
# bacha, potřebuji prvek uložiť in-place |
1770 |
1814 |
cell[1] = self.node_pf_scatter_plot(nodes, cell_stats) |
cell[1] = self.node_pf_scatter_plot(nodes, cell_stats) |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1785 |
1829 |
def node_pf_scatter_plot(self, nodes, cell_stats): |
def node_pf_scatter_plot(self, nodes, cell_stats): |
1786 |
1830 |
pos = getattr(nodes, self.sb_item.space) |
pos = getattr(nodes, self.sb_item.space) |
1787 |
1831 |
symbol_size = self.param.getValues()['node (pixel) size'][0] |
symbol_size = self.param.getValues()['node (pixel) size'][0] |
1788 |
|
|
|
|
1832 |
|
plot_widget = self.sb_item.central_widget |
1789 |
1833 |
# zas, нет ножек - нет мультиков |
# zas, нет ножек - нет мультиков |
1790 |
1834 |
# node_pf_estimations nemusejí bejt |
# node_pf_estimations nemusejí bejt |
1791 |
1835 |
try: |
try: |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1802 |
1846 |
# tuším, že je to neunosně drahý |
# tuším, že je to neunosně drahý |
1803 |
1847 |
list_of_dicts = list({'pos': pos[i], 'size':symbol_size, 'pen': colors[i], 'brush':colors[i], 'symbol':'o'} for i in range(len(pos))) |
list_of_dicts = list({'pos': pos[i], 'size':symbol_size, 'pen': colors[i], 'brush':colors[i], 'symbol':'o'} for i in range(len(pos))) |
1804 |
1848 |
plot_item = pg.ScatterPlotItem(list_of_dicts) |
plot_item = pg.ScatterPlotItem(list_of_dicts) |
1805 |
|
self.sb_item.plotWidget.addItem(plot_item) |
|
|
1849 |
|
plot_widget.addItem(plot_item) |
1806 |
1850 |
return plot_item |
return plot_item |
1807 |
1851 |
|
|
1808 |
1852 |
except BaseException as e: |
except BaseException as e: |
1809 |
1853 |
msg = "node_pf_coloring has problems " |
msg = "node_pf_coloring has problems " |
1810 |
1854 |
error_msg = self.__class__.__name__ + ": " + msg + repr(e) |
error_msg = self.__class__.__name__ + ": " + msg + repr(e) |
1811 |
1855 |
print(error_msg) |
print(error_msg) |
1812 |
|
self.error.emit(error_msg) |
|
|
1856 |
|
#self.error.emit(error_msg) |
1813 |
1857 |
# simple coloring |
# simple coloring |
1814 |
1858 |
event = cell_stats['event'] |
event = cell_stats['event'] |
1815 |
1859 |
color = self.get_color(event) |
color = self.get_color(event) |
1816 |
1860 |
#symbolSize = np.sqrt(nodes.w / min(nodes.w)) # not bad |
#symbolSize = np.sqrt(nodes.w / min(nodes.w)) # not bad |
1817 |
|
return self.sb_item.plotWidget.plot(pos, pen=None, symbol='o', symbolPen=color, symbolBrush=color, symbolSize=symbol_size, name='IS localized nodes') |
|
|
1861 |
|
return plot_widget.plot(pos, pen=None, symbol='o', symbolPen=color, symbolBrush=color, symbolSize=symbol_size, name='IS localized nodes') |
1818 |
1862 |
|
|
1819 |
1863 |
|
|
1820 |
1864 |
|
|
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1826 |
1870 |
otherwise function redraw items in self.cells |
otherwise function redraw items in self.cells |
1827 |
1871 |
""" |
""" |
1828 |
1872 |
symbol_size = self.param.getValues()['node (pixel) size'][0] |
symbol_size = self.param.getValues()['node (pixel) size'][0] |
1829 |
|
|
|
|
1873 |
|
plot_widget = self.sb_item.central_widget |
1830 |
1874 |
if nodes is None: |
if nodes is None: |
1831 |
1875 |
for cell in self.cells: |
for cell in self.cells: |
1832 |
1876 |
nodes, plot_item, cell_stats = cell |
nodes, plot_item, cell_stats = cell |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1835 |
1879 |
# protože nikdo neví co tam bylo před tím |
# protože nikdo neví co tam bylo před tím |
1836 |
1880 |
# takhle, nechce se mi drbat s tím, co tam bylo před tím |
# takhle, nechce se mi drbat s tím, co tam bylo před tím |
1837 |
1881 |
# komplikace ze strany pyqtgraph |
# komplikace ze strany pyqtgraph |
1838 |
|
self.sb_item.plotWidget.removeItem(plot_item) |
|
|
1882 |
|
plot_widget.removeItem(plot_item) |
1839 |
1883 |
|
|
1840 |
1884 |
# draw |
# draw |
1841 |
1885 |
pos = getattr(nodes, self.sb_item.space) |
pos = getattr(nodes, self.sb_item.space) |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1845 |
1889 |
color = self.get_color(event) |
color = self.get_color(event) |
1846 |
1890 |
#symbolSize = np.sqrt(nodes.w / min(nodes.w)) # not bad |
#symbolSize = np.sqrt(nodes.w / min(nodes.w)) # not bad |
1847 |
1891 |
# bacha, potřebuji prvek uložiť in-place |
# bacha, potřebuji prvek uložiť in-place |
1848 |
|
cell[1] = self.sb_item.plotWidget.plot(pos, pen=None, symbol='o',\ |
|
|
1892 |
|
cell[1] = plot_widget.plot(pos, pen=None, symbol='o',\ |
1849 |
1893 |
symbolPen=color, symbolBrush=color, symbolSize=symbol_size, name='IS localized nodes') |
symbolPen=color, symbolBrush=color, symbolSize=symbol_size, name='IS localized nodes') |
1850 |
1894 |
|
|
1851 |
1895 |
# máme nodes, tj. jedeme poprvé |
# máme nodes, tj. jedeme poprvé |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1857 |
1901 |
event = cell_stats['event'] |
event = cell_stats['event'] |
1858 |
1902 |
color = self.get_color(event) |
color = self.get_color(event) |
1859 |
1903 |
#symbolSize = np.sqrt(nodes.w / min(nodes.w)) # not bad |
#symbolSize = np.sqrt(nodes.w / min(nodes.w)) # not bad |
1860 |
|
plot_item = self.sb_item.plotWidget.plot(pos, pen=None, symbol='o',\ |
|
|
1904 |
|
plot_item = plot_widget.plot(pos, pen=None, symbol='o',\ |
1861 |
1905 |
symbolPen=color, symbolBrush=color, symbolSize=symbol_size, name='IS localized nodes') |
symbolPen=color, symbolBrush=color, symbolSize=symbol_size, name='IS localized nodes') |
1862 |
1906 |
|
|
1863 |
1907 |
# uložíme data |
# uložíme data |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1874 |
1918 |
otherwise function redraw items in self.cells |
otherwise function redraw items in self.cells |
1875 |
1919 |
""" |
""" |
1876 |
1920 |
symbol_size = self.param.getValues()['node (pixel) size'][0] |
symbol_size = self.param.getValues()['node (pixel) size'][0] |
1877 |
|
|
|
|
1921 |
|
plot_widget = self.sb_item.central_widget |
1878 |
1922 |
if nodes is None: |
if nodes is None: |
1879 |
1923 |
# odebereme prvky z hlavního plotu |
# odebereme prvky z hlavního plotu |
1880 |
1924 |
# zde je třeba prvky vygenerovat znovu |
# zde je třeba prvky vygenerovat znovu |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1882 |
1926 |
# takhle, nechce se mi drbat s tím, co tam bylo před tím |
# takhle, nechce se mi drbat s tím, co tam bylo před tím |
1883 |
1927 |
# komplikace ze strany pyqtgraph |
# komplikace ze strany pyqtgraph |
1884 |
1928 |
for nodes, plot_item, cell_stats in self.cells: |
for nodes, plot_item, cell_stats in self.cells: |
1885 |
|
self.sb_item.plotWidget.removeItem(plot_item) |
|
|
1929 |
|
plot_widget.removeItem(plot_item) |
1886 |
1930 |
|
|
1887 |
1931 |
event = cell_stats['event'] |
event = cell_stats['event'] |
1888 |
1932 |
cell_probability = cell_stats['cell_probability'] |
cell_probability = cell_stats['cell_probability'] |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1903 |
1947 |
color = self.get_color(event, blue_intensity) |
color = self.get_color(event, blue_intensity) |
1904 |
1948 |
#symbolSize = np.sqrt(nodes.w / min(nodes.w)) # not bad |
#symbolSize = np.sqrt(nodes.w / min(nodes.w)) # not bad |
1905 |
1949 |
# bacha, potřebuji prvek vložit zpätky |
# bacha, potřebuji prvek vložit zpätky |
1906 |
|
cell[1] = self.sb_item.plotWidget.plot(pos, pen=None, symbol='o',\ |
|
|
1950 |
|
cell[1] = plot_widget.plot(pos, pen=None, symbol='o',\ |
1907 |
1951 |
symbolPen=color, symbolBrush=color, symbolSize=symbol_size, name='IS localized nodes') |
symbolPen=color, symbolBrush=color, symbolSize=symbol_size, name='IS localized nodes') |
1908 |
1952 |
|
|
1909 |
1953 |
# máme nodes, tj. jedeme poprvé |
# máme nodes, tj. jedeme poprvé |
|
... |
... |
class VoronoiEstimationWidget(pg.LayoutWidget): |
1936 |
1980 |
#x, y = (*getattr(nodes, self.sb_item.space).T,) |
#x, y = (*getattr(nodes, self.sb_item.space).T,) |
1937 |
1981 |
|
|
1938 |
1982 |
#symbolSize = np.sqrt(nodes.w / min(nodes.w)) # not bad |
#symbolSize = np.sqrt(nodes.w / min(nodes.w)) # not bad |
1939 |
|
plot_item = self.sb_item.plotWidget.plot(pos, pen=None, symbol='o',\ |
|
|
1983 |
|
plot_item = plot_widget.plot(pos, pen=None, symbol='o',\ |
1940 |
1984 |
symbolPen=color, symbolBrush=color, symbolSize=symbol_size, name='IS localized nodes') |
symbolPen=color, symbolBrush=color, symbolSize=symbol_size, name='IS localized nodes') |
1941 |
1985 |
|
|
1942 |
1986 |
# uložíme data |
# uložíme data |
|
... |
... |
class CandidatesWidget(pg.LayoutWidget): |
2037 |
2081 |
# 3 |
# 3 |
2038 |
2082 |
# |
# |
2039 |
2083 |
self.gradient = pg.GradientWidget(self, orientation='right') |
self.gradient = pg.GradientWidget(self, orientation='right') |
|
2084 |
|
self.gradient.setColorMap(pg.colormap.ColorMap((0,1),\ |
|
2085 |
|
[(255, 255, 255, 255), (67, 0, 81, 255)])) |
2040 |
2086 |
self.addWidget(self.gradient, row=2, col=1) |
self.addWidget(self.gradient, row=2, col=1) |
2041 |
2087 |
|
|
|
2088 |
|
|
|
2089 |
|
|
2042 |
2090 |
#E pens, i.e. handles of PlotItem |
#E pens, i.e. handles of PlotItem |
2043 |
2091 |
self.pens = [] |
self.pens = [] |
2044 |
2092 |
|
|
|
... |
... |
class CandidatesWidget(pg.LayoutWidget): |
2046 |
2094 |
def run_stm(self): |
def run_stm(self): |
2047 |
2095 |
#č indikace |
#č indikace |
2048 |
2096 |
#self.setDisabled(True) |
#self.setDisabled(True) |
|
2097 |
|
plot_widget = self.sb_item.central_widget |
2049 |
2098 |
with pg.BusyCursor(): |
with pg.BusyCursor(): |
2050 |
2099 |
|
|
2051 |
2100 |
color_map = self.gradient.colorMap() |
color_map = self.gradient.colorMap() |
|
... |
... |
class CandidatesWidget(pg.LayoutWidget): |
2068 |
2117 |
mincb = np.nanmin(array) |
mincb = np.nanmin(array) |
2069 |
2118 |
if maxcb > maxvalue: |
if maxcb > maxvalue: |
2070 |
2119 |
maxvalue = maxcb |
maxvalue = maxcb |
|
2120 |
|
maxitem = cb[np.nanargmax(array)] |
2071 |
2121 |
if mincb < minvalue: |
if mincb < minvalue: |
2072 |
2122 |
minvalue = mincb |
minvalue = mincb |
2073 |
2123 |
|
|
2074 |
|
|
|
2075 |
|
|
|
|
2124 |
|
#č zvlášť nakreslím maximální hodnotu |
|
2125 |
|
pos = getattr(maxitem, self.sb_item.space) |
|
2126 |
|
max_item = plot_widget.plot(pos, data=maxvalue, pen=None, symbol='t1',\ |
|
2127 |
|
symbolBrush=color_map.mapToQColor(1)) |
|
2128 |
|
max_item.setZValue(130) |
|
2129 |
|
self.pens.append(max_item) |
|
2130 |
|
|
2076 |
2131 |
#č a teď jdeme! |
#č a teď jdeme! |
2077 |
2132 |
for id, cb in self.sb_item.sample_box.candidates_index.items(): |
for id, cb in self.sb_item.sample_box.candidates_index.items(): |
2078 |
2133 |
array = getattr(cb, attr) |
array = getattr(cb, attr) |
|
... |
... |
class CandidatesWidget(pg.LayoutWidget): |
2089 |
2144 |
#č sehnal jsem toto ze zdrojaků pyqtgraph |
#č sehnal jsem toto ze zdrojaků pyqtgraph |
2090 |
2145 |
style = dict(pen=None, symbol='o', symbolSize=self.sb_item.px_size, symbolPen=pg.mkPen(None)) |
style = dict(pen=None, symbol='o', symbolSize=self.sb_item.px_size, symbolPen=pg.mkPen(None)) |
2091 |
2146 |
style['symbolBrush'] = np.array([pg.functions.mkBrush(*x) for x in color_map.map(norm_values)]) |
style['symbolBrush'] = np.array([pg.functions.mkBrush(*x) for x in color_map.map(norm_values)]) |
2092 |
|
pen = self.sb_item.plotWidget.plot(pos, data=values, **style) |
|
|
2147 |
|
pen = plot_widget.plot(pos, data=values, **style) |
2093 |
2148 |
pen.setZValue(-1) |
pen.setZValue(-1) |
2094 |
2149 |
self.pens.append(pen) |
self.pens.append(pen) |
2095 |
2150 |
|
|